X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fas3%2Fabc.c;h=3b72123b78bec6eb29cde281a60ddfa7d6942c03;hb=431de080cd881b8d00c4cc888090f22f79021311;hp=27c43319e1ab7ab62e58e0aabcd51b66fb3aa27b;hpb=4e990c50e8224621ac557f21ed3bd937ba0bbff3;p=swftools.git diff --git a/lib/as3/abc.c b/lib/as3/abc.c index 27c4331..3b72123 100644 --- a/lib/as3/abc.c +++ b/lib/as3/abc.c @@ -28,124 +28,6 @@ char stringbuffer[2048]; -dict_t* dict_new() { - dict_t*d = malloc(sizeof(dict_t)); - memset(d, 0, sizeof(dict_t)); - return d; -} - -void dict_free(dict_t*dict) { - if(dict->d) - free(dict->d);dict->d = 0; - free(dict); -} - -const char*dict_getstr(dict_t*dict, int nr) { - if(nr > dict->num || nr<0) { - printf("error: reference to string %d in dict\n"); - return 0; - } - return dict->d[nr].name; -} -char*dict_getdata(dict_t*dict, int nr) { - if(nr > dict->num || nr<0) { - printf("error: reference to string %d in dict\n"); - return 0; - } - return dict->d[nr].data; -} -int dict_append(dict_t*dict, const char*name, void*data) { - while(dict->size <= dict->num) { - dict->size += 64; - if(!dict->d) { - dict->d = malloc(sizeof(dict_entry_t)*dict->size); - } else { - dict->d = realloc(dict->d, sizeof(dict_entry_t)*dict->size); - } - } - if(name) { - dict->d[dict->num].name = strdup(name); - } else { - dict->d[dict->num].name = 0; - } - dict->d[dict->num].data = data; - return dict->num++; -} -int dict_find(dict_t*dict, const char*name) -{ - if(!name) - name = ""; - int t; - for(t=0;tnum;t++) { - if(dict->d[t].name && !strcmp(dict->d[t].name,name)) - return t; - } - return -1; -} -int dict_find2(dict_t*dict, const char*name, void*data) -{ - if(!name) - name = ""; - int t; - for(t=0;tnum;t++) { - if(dict->d[t].name && !strcmp(dict->d[t].name,name) && dict->d[t].data == data) - return t; - } - return -1; -} -int dict_update(dict_t*dict, const char*name, void*data) { - int pos = dict_find(dict, name); - if(pos>=0) { - dict->d[pos].data = data; - return pos; - } - return dict_append(dict, name, data); -} -int dict_append_if_new(dict_t*dict, const char*name, void*data) { - int pos = dict_find(dict, name); - if(pos>=0) - return pos; - return dict_append(dict, name, data); -} -int dict_append_if_new2(dict_t*dict, const char*name, void*data) { - int pos = dict_find2(dict, name, data); - if(pos>=0) - return pos; - return dict_append(dict, name, data); -} - -typedef struct _commonlist { - void*entry; - struct _commonlist*next; - struct _commonlist*last[0]; -} commonlist_t; - -int list_length(void*_list) -{ - commonlist_t*l = (commonlist_t*)_list; - int n=0; - while(l) { - l = l->next; - n++; - } - return n; -} -void list_append(void*_list, void*entry) -{ - commonlist_t**list = (commonlist_t**)_list; - commonlist_t* n = 0; - if(!*list) { - n = malloc(sizeof(commonlist_t)+sizeof(commonlist_t*)); - *list = n; - } else { - n = malloc(sizeof(commonlist_t)); - (*list)->last[0]->next = n; - } - n->next = 0; - n->entry = entry; - (*list)->last[0] = n; -} - int swf_GetU30(TAG*tag) { U32 shift = 0;