From 8d05bd5468ad535c1c54e539094a247e94520fb3 Mon Sep 17 00:00:00 2001 From: mescalinum Date: Fri, 7 Oct 2011 19:02:35 +0000 Subject: fix svn path=/trunk/externals/loaders/tclpd/; revision=15540 --- tcl_class.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) (limited to 'tcl_class.c') diff --git a/tcl_class.c b/tcl_class.c index 25af02d..b5d98d9 100644 --- a/tcl_class.c +++ b/tcl_class.c @@ -31,7 +31,7 @@ static inline list_node_t* list_add(list_node_t* head, const char* k, void* v) { list_node_t* n = (list_node_t*)malloc(sizeof(list_node_t)); n->next = head; - n->k = k; + n->k = strdup(k); n->v = v; return n; } @@ -45,6 +45,7 @@ static inline list_node_t* list_remove(list_node_t* head, const char* k) { tmp = head; head = head->next; + free(tmp->k); free(tmp); } @@ -71,29 +72,17 @@ static inline void* list_get(list_node_t* head, const char* k) while(head) { if(strcmp(head->k, k) == 0) + { return head->v; + } head = head->next; } +#ifdef DEBUG + debug_print("list_get(%lx, %s) = NULL\n", head, k); +#endif return (void*)0; } -static inline void list_print(list_node_t* head) -{ - if(!head) - { - printf("NULL\n"); - return; - } - while(head) - { - printf("%s=x%8.8X", head->k, head->v); - if(head->next) printf(", "); - head = head->next; - } - printf("\n"); -} - - static list_node_t* class_tbl[CLASS_TABLE_SIZE]; static list_node_t* object_tbl[OBJECT_TABLE_SIZE]; -- cgit v1.2.1