xbt_dynar_set(variable->content,0,&val);
} else {
- if (variable->max && xbt_dynar_length(variable->content) == variable->max)
+ if (variable->max && xbt_dynar_length(variable->content) == (unsigned long)variable->max)
THROW3(mismatch_error,0,
"Cannot add value %d to the config element %s since it's already full (size=%d)",
val,name,variable->max);
int key_len,
void *data,
void_f_pvoid_t *free_ctn) {
- xbt_assert(dict);
- unsigned int hash_code = xbt_dict_hash_ext(key,key_len) % dict->table_size;
+ unsigned int hash_code;
xbt_dictelm_t current, previous = NULL;
+ xbt_assert(dict);
+
+ hash_code = xbt_dict_hash_ext(key,key_len) % dict->table_size;
current = dict->table[hash_code];
while (current != NULL &&
void *xbt_dict_get_ext(xbt_dict_t dict,
const char *key,
int key_len) {
- xbt_assert(dict);
- unsigned int hash_code = xbt_dict_hash_ext(key,key_len) % dict->table_size;
+
+ unsigned int hash_code;
xbt_dictelm_t current;
+ xbt_assert(dict);
+
+ hash_code = xbt_dict_hash_ext(key,key_len) % dict->table_size;
+
current = dict->table[hash_code];
while (current != NULL &&
(key_len != current->key_len || strncmp(key, current->key, key_len))) {
*/
void *xbt_dict_get(xbt_dict_t dict,
const char *key) {
- xbt_assert(dict);
- unsigned int hash_code = xbt_dict_hash(key) % dict->table_size;
+
+ unsigned int hash_code ;
xbt_dictelm_t current;
+ xbt_assert(dict);
+
+ hash_code = xbt_dict_hash(key) % dict->table_size;
+
current = dict->table[hash_code];
while (current != NULL && (strcmp(key, current->key))) {
current = current->next;
void xbt_dict_remove_ext(xbt_dict_t dict,
const char *key,
int key_len) {
- xbt_assert(dict);
- unsigned int hash_code = xbt_dict_hash_ext(key,key_len) % dict->table_size;
+
+ unsigned int hash_code ;
xbt_dictelm_t current, previous = NULL;
+ xbt_assert(dict);
+
+ hash_code = xbt_dict_hash_ext(key,key_len) % dict->table_size;
+
current = dict->table[hash_code];
while (current != NULL &&
(key_len != current->key_len || strncmp(key, current->key, key_len))) {
* \param dict the dict
*/
void xbt_dict_reset(xbt_dict_t dict) {
- xbt_assert(dict);
+
int i;
xbt_dictelm_t current, previous = NULL;
+
+ xbt_assert(dict);
if (dict->count == 0)
return;
* Add an already mallocated element to a dictionary.
*/
void xbt_dict_add_element(xbt_dict_t dict, xbt_dictelm_t element) {
- xbt_assert(dict);
- int hashcode = xbt_dict_hash_ext(element->key,element->key_len) % dict->table_size;
+
+ int hashcode;
+
+ xbt_assert(dict);
+
+ hashcode = xbt_dict_hash_ext(element->key,element->key_len) % dict->table_size;
element->next = dict->table[hashcode];
dict->table[hashcode] = element;
}
* \brief Move to the next element.
*/
void xbt_dict_cursor_step(xbt_dict_cursor_t cursor) {
+
+
+ xbt_dictelm_t current ;
+ int line;
+
DEBUG0("xbt_dict_cursor_step");
xbt_assert(cursor);
- xbt_dictelm_t current = cursor->current;
- int line = cursor->line;
+ current = cursor->current;
+ line = cursor->line;
if (cursor->dict != NULL) {
int xbt_dict_cursor_get_or_free(xbt_dict_cursor_t *cursor,
char **key,
void **data) {
- DEBUG0("xbt_dict_get_or_free");
xbt_dictelm_t current;
+ DEBUG0("xbt_dict_get_or_free");
+
+
if (!cursor || !(*cursor))
return FALSE;
xbt_dynar_push(lens,&thislen);
}
- TRY {
- xbt_multidict_set_ext(mdict, keys, lens, data, free_ctn);
- } CLEANUP {
- xbt_dynar_free(&lens);
- } CATCH(e) {
+ /*TRY
+ {
+ xbt_multidict_set_ext(mdict, keys, lens, data, free_ctn);
+ }
+ CLEANUP
+ {
+ xbt_dynar_free(&lens);
+ }
+ CATCH(e)
+ {
RETHROW;
+ }*/
+
+ TRY
+ {
+ xbt_multidict_set_ext(mdict, keys, lens, data, free_ctn);
+ }
+ CLEANUP
+ {
+ xbt_dynar_free(&lens);
}
+ CATCH(e)
+ {
+ RETHROW;
+ }
+
+
+
+
+
+
}
/** \brief Insert \e data under all the keys contained in \e keys, providing their sizes in \e lens.
pvoid_f_void_t new_f,
void_f_pvoid_t free_f,
void_f_pvoid_t reset_f) {
+
+
+ xbt_mallocator_t m;
+
xbt_assert0(size > 0, "size must be positive");
- xbt_assert0(new_f != NULL && free_f != NULL && reset_f != NULL,
- "invalid parameter");
- xbt_mallocator_t m = xbt_new0(s_xbt_mallocator_t, 1);
+ xbt_assert0(new_f != NULL && free_f != NULL && reset_f != NULL,"invalid parameter");
+
+ m = xbt_new0(s_xbt_mallocator_t, 1);
m->objects = xbt_new0(void*, size);
m->max_size = size;
* \see xbt_mallocator_new()
*/
void xbt_mallocator_free(xbt_mallocator_t m) {
- xbt_assert0(m != NULL, "Invalid parameter");
int i;
+ xbt_assert0(m != NULL, "Invalid parameter");
+
+
for (i = 0; i < m->current_size; i++) {
m->free_f(m->objects[i]);
}
* \see xbt_mallocator_release()
*/
void *xbt_mallocator_get(xbt_mallocator_t m) {
+
+void *object;
xbt_assert0(m != NULL, "Invalid parameter");
- void *object;
+
if (m->current_size > 0) {
/* there is at least an available object */
object = m->objects[--m->current_size];