summaryrefslogtreecommitdiffstats
path: root/tools/ArtChecker/badlist.cpp
blob: bcce4ca1cbf1fbf946040b6226e37b5e356a4c13 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "badlist.hpp"
#include <cstring>
#include<stdio.h>

badlist::badlist ()
{
    max_items=200;
    data_array=new entity_data[max_items];
	index = 0;
    totalmemoryusage =0;
    for(unsigned int i=0;i<max_items;i++)
    {             
        strcpy(data_array[i].name," ");
        data_array[i].occurances=0;
        data_array[i].size=0;
    }
}
badlist::badlist (const unsigned int arraysize)
{
    max_items=arraysize;
    data_array=new entity_data[max_items];
	index = 0;
    totalmemoryusage =0;
    for(unsigned int i=0;i<max_items;i++)
    {             
        strcpy(data_array[i].name," ");
        data_array[i].occurances=0;
        data_array[i].size=0;
    }
}




badlist::~badlist ()
{
}

int badlist::add(const char* name,const unsigned int occurances,const unsigned int size)
{
	if (index<max_items-1)
	{
		strcpy( data_array[index].name,name);
        data_array[index].occurances=occurances;
        data_array[index].size=size;
        totalmemoryusage+=size;
		index++;
		return 0;
	}
	else
	{
		return 1;
	}
}
	
int badlist::inlist(const char* name)
{
    unsigned int i=0;
    do 
    {
        if(strcmp(name,data_array[i].name) ==0)
        {
            //printf("%s found in list \n",name);
            return 1;
        }
        i++;
    } while (i<index);

    return 0;
}

int badlist::getsize()
{   	
   return totalmemoryusage;		
}

int badlist::getindexcount()
{
    return index;
}


int badlist::printverbose()
{
    for (unsigned int i=0;i<index;i++)
    {
        printf("%-30s: size in bytes: %6i \n",data_array[i].name,data_array[i].size);
    }
    return 0;
}