/* dict - a generic dictionnary, variation over the B-tree concept */
-/* Authors: Martin Quinson */
-/* Copyright (C) 2003 the OURAGAN project. */
+/* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
- under the terms of the license (GNU LGPL) which comes with this package. */
+ * under the terms of the license (GNU LGPL) which comes with this package. */
#include "dict_private.h" /* prototypes of this module */
void *data,
void_f_pvoid_t *free_f,
/*OUT*/s_xbt_dictelm_t **pp_elm) {
- xbt_error_t errcode = no_error;
s_xbt_dictelm_t *p_elm = NULL;
p_elm = xbt_new(s_xbt_dictelm_t,1);
xbt_dynar_free(&(p_elm->sub));
if (p_elm->key) {
- xbt_free(p_elm->key);
+ free(p_elm->key);
}
if (p_elm->free_f && p_elm->content) {
p_elm->free_f(p_elm->content);
}
- xbt_free(p_elm);
+ free(p_elm);
*pp_elm = NULL;
}
}
CDEBUG5(dict_search, "search child [%.*s] under [%.*s] (len=%lu)",
key_len, key,
- p_elm?p_elm->key_len:6, p_elm?p_elm->key:"(head)",
+ p_elm?(p_elm->key_len?p_elm->key_len:6):6, p_elm?(p_elm->key?p_elm->key:"(null)"):"(head)",
(p_elm&&p_elm->sub)?xbt_dynar_length(p_elm->sub):0);
*p_match = m;
CDEBUG5(dict_search, "search [%.*s] in [%.*s] => %s",
key_len, key,
- p_elm?p_elm->key_len:6, p_elm?p_elm->key:"(head)",
+ p_elm?(p_elm->key_len?p_elm->key_len:6):6, p_elm?(p_elm->key?p_elm->key:"(null)"):"(head)",
( m == 0 ? "no child have a common prefix" :
( m == 1 ? "selected child have exactly this key" :
( m == 2 ? "selected child constitutes a prefix" :
CDEBUG0(dict_add, "--> Change the value of head");
_xbt_dictelm_change_value(p_head, data, free_f);
- xbt_free(key); /* Keep the key used in the tree */
+ free(key); /* Keep the key used in the tree */
return;
}
CDEBUG1(dict_add, "-> Change the value of the child %p", (void*)p_child);
_xbt_dictelm_change_value(p_child, data, free_f);
- xbt_free(key);
+ free(key);
return;
}
int key_len,
int offset,
void **data) {
- void *res;
CDEBUG3(dict_search, "Search %.*s in %p", key_len, key, (void*)p_head);
head->content = child->content;
head->free_f = child->free_f;
- xbt_free(head->key);
+ free(head->key);
head->key = child->key;
head->key_len = child->key_len;
xbt_dynar_free_container(&(head->sub)) ;
head->sub = child->sub;
- xbt_free(child);
+ free(child);
}
/**
printf("%.*s|(%d)", key_len-offset, key_string + offset, offset);
- xbt_free(key_string);
+ free(key_string);
}
}