X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fgfxtools.c;h=2e080de30e49bdc19d14e42bb833819a4b31a4e1;hp=55c4925f508663a9a8129d7b930c493c6c8feb67;hb=6c8f037f0f76ce4b28b80a2133e4150d93012ef7;hpb=b174b88412be23f82cb844d1d99f9c6761c94cbb diff --git a/lib/gfxtools.c b/lib/gfxtools.c index 55c4925..2e080de 100644 --- a/lib/gfxtools.c +++ b/lib/gfxtools.c @@ -1152,3 +1152,46 @@ void gfximage_save_jpeg(gfximage_t*img, char*filename, int quality) jpeg_save(data, img->width, img->height, quality, filename); } +gfxparams_t* gfxparams_new() +{ + return (gfxparams_t*)rfx_calloc(sizeof(gfxparams_t)); +} + +void gfxparams_store(gfxparams_t*params, const char*key, const char*value) +{ + gfxparam_t*o = params->params; + while(o) { + if(!strcmp(key, o->key)) { + /* overwrite old value */ + free((void*)o->value); + o->value = strdup(value); + return; + } + o = o->next; + } + gfxparam_t*p = (gfxparam_t*)malloc(sizeof(gfxparam_t)); + p->key = strdup(key); + p->value = strdup(value); + p->next = 0; + + if(params->last) { + params->last->next = p; + params->last = p; + } else { + params->params = p; + params->last = p; + } +} + +void gfxparams_free(gfxparams_t*params) +{ + gfxparam_t*p = params->params; + while(p) { + gfxparam_t*next = p->next; + free((void*)p->key); + if(p->value) free((void*)p->value); + free(p); + p = next; + } +} +