//delete a param_list void param_list_delete(struct param_list *p){ if(!p) return; param_list_delete(p->next); type_delete(p->type); free(p); }
void param_list_delete(struct param_list *p) { if (!p) return; // delete from end of list param_list_delete(p->next); // free node free(p->name); type_delete(p->type); free(p); }
void param_list_add(ParamList **root, const char *key, const char *value, int value_size) { ParamList *pl = (ParamList*)malloc(sizeof(ParamList)); int key_len = strlen(key); param_list_delete(root, key); pl->next = *root; pl->key = malloc(key_len + 1); memcpy(pl->key, key, key_len + 1); pl->value = malloc(value_size); memcpy(pl->value, value, value_size); pl->value_size = value_size; *root = pl; }