/* 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. */
-
-#include "gras_private.h"
#include "dict_private.h"
#include <stdlib.h> /* malloc() */
#include <stdio.h>
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(dict,gros,
+GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(dict,xbt,
"Dictionaries provide the same functionnalities than hash tables");
/*####[ Private prototypes ]#################################################*/
*
* Creates and initialize a new dictionnary
*/
-gras_error_t
-gras_dict_new(gras_dict_t **whereto) {
- gras_dict_t *dict;
-
- if (!(dict = calloc(1, sizeof(gras_dict_t))))
- RAISE_MALLOC;
-
- dict->head=NULL;
-
- *whereto = dict;
-
- return no_error;
+gras_dict_t *
+gras_dict_new(void) {
+ gras_dict_t *res= gras_new(gras_dict_t,1);
+ res->head=NULL;
+ return res;
}
/**
* gras_dict_free:
* set the @data in the structure under the @key, which can be any kind
* of data, as long as its length is provided in @key_len.
*/
-gras_error_t
+void
gras_dict_set_ext(gras_dict_t *p_dict,
- const char *key,
- int key_len,
- void *data,
- void_f_pvoid_t *free_ctn) {
+ const char *key,
+ int key_len,
+ void *data,
+ void_f_pvoid_t *free_ctn) {
gras_assert(p_dict);
- return gras_dictelm_set_ext(&(p_dict->head),
- key, key_len, data, free_ctn);
+ gras_dictelm_set_ext(&(p_dict->head),
+ key, key_len, data, free_ctn);
}
/**
* set the @data in the structure under the @key, which is a
* null terminated string.
*/
-gras_error_t
+void
gras_dict_set(gras_dict_t *p_dict,
const char *key,
void *data,
gras_assert(p_dict);
- return gras_dictelm_set(&(p_dict->head), key, data, free_ctn);
+ gras_dictelm_set(&(p_dict->head), key, data, free_ctn);
}
/**
* function to output the data. If NULL, data won't be displayed.
*/
-gras_error_t
+void
gras_dict_dump(gras_dict_t *dict,
void_f_pvoid_t *output) {
printf("Dict %p:\n", (void*)dict);
- return gras_dictelm_dump(dict ? dict->head: NULL, output);
+ gras_dictelm_dump(dict ? dict->head: NULL, output);
}