diff -r feb2f1e115c6 -r c858850f3d3a src/server/util/object.c --- a/src/server/util/object.c Mon May 06 14:54:40 2013 +0200 +++ b/src/server/util/object.c Thu May 09 13:19:51 2013 +0200 @@ -35,23 +35,23 @@ -httpd_object* object_new(char *name) { +httpd_object* object_new(pool_handle_t *pool, char *name) { // TODO: Speicherverwaltung - httpd_object *obj = malloc(sizeof(httpd_object)); + httpd_object *obj = pool_malloc(pool, sizeof(httpd_object)); + obj->pool = pool; obj->name = name; obj->path = NULL; // create directive table - obj->dt = calloc(sizeof(struct dtable), NUM_NSAPI_TYPES - 1); + obj->dt = pool_calloc(pool, NUM_NSAPI_TYPES - 1, sizeof(struct dtable)); obj->nd = NUM_NSAPI_TYPES - 1; return obj; } void object_free(httpd_object *obj) { - free(obj->name); - // TODO: free objects - free(obj->dt); + //free(obj->name); + //free(obj->dt); } @@ -60,14 +60,14 @@ // allocate space for the new directive //l->dirs = realloc(l->dirs, (l->ndir+1)*sizeof(void*)); - /* TODO: aus irgend einem Grund funktioniert realloc nicht. warum?? */ + // TODO: use realloc - directive **drs = malloc((l->ndir+1)*sizeof(void*)); + directive **drs = pool_malloc(obj->pool, (l->ndir+1)*sizeof(void*)); for(int i=0;indir;i++) { drs[i] = l->dirs[i]; } if(l->dirs != NULL) { - free(l->dirs); + pool_free(obj->pool, l->dirs); } l->dirs = drs; @@ -95,31 +95,6 @@ os->pos++; } - - -// TODO: remove -httpd_objset* create_test_objset() { - httpd_objset *objset = malloc(sizeof(httpd_objset)); - objset->obj = calloc(1, sizeof(httpd_object*)); - - httpd_object *obj = object_new("default"); - objset->obj[0] = obj; - objset->pos = 1; - - directive *d1 = malloc(sizeof(directive)); - d1->func = get_function("test-nametrans"); - d1->param = NULL; - object_add_directive(obj, d1, NSAPINameTrans); - - directive *d2 = malloc(sizeof(directive)); - d2->func = get_function("test-service"); - d2->param = NULL; - object_add_directive(obj, d2, NSAPIService); - - return objset; -} - - void httpobjconf_add_object(HTTPObjectConfig *conf, httpd_object *obj) { conf->nobj++; conf->objects = realloc(conf->objects, conf->nobj * sizeof(void*));