1.1 --- a/sourcepawn/compiler/sctracker.c Thu Nov 02 20:48:15 2006 +0000
1.2 +++ b/sourcepawn/compiler/sctracker.c Fri Nov 03 06:14:43 2006 +0000
1.3 @@ -1,10 +1,94 @@
1.4 #include <malloc.h>
1.5 +#include <string.h>
1.6 #include <assert.h>
1.7 #include "sc.h"
1.8 #include "sctracker.h"
1.9
1.10 memuse_list_t *heapusage = NULL;
1.11 memuse_list_t *stackusage = NULL;
1.12 +funcenum_t *firstenum = NULL;
1.13 +funcenum_t *lastenum = NULL;
1.14 +
1.15 +void funcenums_free()
1.16 +{
1.17 + funcenum_t *e, *next;
1.18 +
1.19 + e = firstenum;
1.20 + while (e)
1.21 + {
1.22 + functag_t *tag, *nexttag;
1.23 + tag = e->first;
1.24 + while (tag)
1.25 + {
1.26 + nexttag = tag->next;
1.27 + free(tag);
1.28 + tag = nexttag;
1.29 + }
1.30 + next = e->next;
1.31 + free(e);
1.32 + e = next;
1.33 + }
1.34 +
1.35 + firstenum = NULL;
1.36 + lastenum = NULL;
1.37 +}
1.38 +
1.39 +funcenum_t *funcenums_find_byval(int value)
1.40 +{
1.41 + funcenum_t *e = firstenum;
1.42 +
1.43 + while (e)
1.44 + {
1.45 + if (e->value == value)
1.46 + {
1.47 + return e;
1.48 + }
1.49 + e = e->next;
1.50 + }
1.51 +
1.52 + return NULL;
1.53 +}
1.54 +
1.55 +funcenum_t *funcenums_add(const char *name)
1.56 +{
1.57 + funcenum_t *e = (funcenum_t *)malloc(sizeof(funcenum_t));
1.58 +
1.59 + memset(e, 0, sizeof(funcenum_t));
1.60 +
1.61 + if (firstenum == NULL)
1.62 + {
1.63 + firstenum = e;
1.64 + lastenum = e;
1.65 + } else {
1.66 + lastenum->next = e;
1.67 + lastenum = e;
1.68 + }
1.69 +
1.70 + strcpy(e->name, name);
1.71 + e->value = pc_addfunctag((char *)name);
1.72 +
1.73 + return e;
1.74 +}
1.75 +
1.76 +functag_t *functags_add(funcenum_t *en, functag_t *src)
1.77 +{
1.78 + functag_t *t = (functag_t *)malloc(sizeof(functag_t));
1.79 +
1.80 + memcpy(t, src, sizeof(functag_t));
1.81 +
1.82 + t->next = NULL;
1.83 +
1.84 + if (en->first == NULL)
1.85 + {
1.86 + en->first = t;
1.87 + en->last = t;
1.88 + } else {
1.89 + en->last->next = t;
1.90 + en->last = t;
1.91 + }
1.92 +
1.93 + return t;
1.94 +}
1.95
1.96 /**
1.97 * Creates a new mem usage tracker entry