X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fq.c;h=67597df414ab06f727eb94d6a6fe422a74279650;hb=b6ebc39257e2814f08a17d8c179c3991c16053ba;hp=fc9f8684256548e89cde59b87623f6ee75a781db;hpb=10b60d36fcf6cc9532bf397866c5bdc3393246eb;p=swftools.git diff --git a/lib/q.c b/lib/q.c index fc9f868..67597df 100644 --- a/lib/q.c +++ b/lib/q.c @@ -113,6 +113,36 @@ int mem_get(mem_t*m, void*data, int length) return length; } +// ------------------------------- median ------------------------------------- + +float medianf(float*a, int n) +{ + int i,j,l,m; + float x; + int k=n&1?n/2:n/2-1; + l=0; + m=n-1; + while(lrest = (unsigned char*)strdup(id); + (*t)->rest = (unsigned char*)strdup((char*)id); (*t)->data = data; return 0; } @@ -359,7 +389,7 @@ static char _trie_put(trielayer_t**t, unsigned const char*id, void*data) char overwrite = 0; if((*t)->rest) overwrite = 1; - (*t)->rest = strdup(""); + (*t)->rest = (unsigned char*)strdup(""); (*t)->data = data; return overwrite; } @@ -367,7 +397,7 @@ static char _trie_put(trielayer_t**t, unsigned const char*id, void*data) static char _trie_remove(trielayer_t*t, unsigned const char*id) { while(t) { - if(t->rest && !strcmp(t->rest, id)) { + if(t->rest && !strcmp((char*)t->rest, (char*)id)) { free(t->rest); t->rest = 0; return 1; @@ -413,7 +443,7 @@ int trie_contains(trie_t*trie, unsigned const char*id) { trielayer_t*t = trie->start; while(t) { - if(t->rest && !strcmp(t->rest, id)) + if(t->rest && !strcmp((char*)t->rest, (char*)id)) return 1; if(!*id) return 0; @@ -425,7 +455,7 @@ void* trie_lookup(trie_t*trie, unsigned const char*id) { trielayer_t*t = trie->start; while(t) { - if(t->rest && !strcmp(t->rest, id)) + if(t->rest && !strcmp((char*)t->rest, (char*)id)) return t->data; if(!*id) return 0; @@ -1343,14 +1373,14 @@ array_t* array_new2(type_t*type) { } void*array_getkey(array_t*array, int nr) { if(nr > array->num || nr<0) { - printf("error: reference to element %d in array[%d]\n", nr, array->num); + fprintf(stderr, "error: reference to element %d in array[%d]\n", nr, array->num); return 0; } return array->d[nr].name; } void*array_getvalue(array_t*array, int nr) { if(nr > array->num || nr<0) { - printf("error: reference to element %d in array[%d]\n", nr, array->num); + fprintf(stderr, "error: reference to element %d in array[%d]\n", nr, array->num); return 0; } return array->d[nr].data;