src/server/object.c

changeset 13
1fdbf4170ef4
parent 12
34aa8001ea53
equal deleted inserted replaced
12:34aa8001ea53 13:1fdbf4170ef4
57 57
58 void object_add_directive(httpd_object *obj, directive *dir, int dt) { 58 void object_add_directive(httpd_object *obj, directive *dir, int dt) {
59 dtable *l = object_get_dtable(obj, dt); 59 dtable *l = object_get_dtable(obj, dt);
60 // allocate space for the new directive 60 // allocate space for the new directive
61 61
62 l->dirs = realloc(l->dirs, (l->ndir+1)*sizeof(void*)); 62 //l->dirs = realloc(l->dirs, (l->ndir+1)*sizeof(void*));
63 /* TODO: aus irgend einem Grund funktioniert realloc nicht. warum?? */ 63 /* TODO: aus irgend einem Grund funktioniert realloc nicht. warum?? */
64 64
65 directive **drs = malloc((l->ndir+1)*sizeof(void*)); 65 directive **drs = malloc((l->ndir+1)*sizeof(void*));
66 for(int i=0;i<l->ndir;i++) { 66 for(int i=0;i<l->ndir;i++) {
67 drs[i] = l->dirs[i]; 67 drs[i] = l->dirs[i];
68 } 68 }
69 free(l->dirs); 69 if(l->dirs != NULL) {
70 free(l->dirs);
71 }
70 l->dirs = drs; 72 l->dirs = drs;
71 73
72 // add directive 74 // add directive
73 l->dirs[l->ndir] = dir; 75 l->dirs[l->ndir] = dir;
74 l->ndir++; 76 l->ndir++;

mercurial