sebastian's fix.

SVN revision: 13117
This commit is contained in:
Carsten Haitzler 2005-01-29 02:13:12 +00:00
parent 44f0d70286
commit cdd37bfdfe
3 changed files with 34 additions and 5 deletions

View File

@ -442,12 +442,17 @@ extern "C" {
char order, sorted;
/* Callback for comparing node values, default is direct comparison */
Ecore_Compare_Cb compare;
/* Callback for freeing node data, default is NULL */
Ecore_Free_Cb free_func;
};
Ecore_Sheap *ecore_sheap_new(Ecore_Compare_Cb compare, int size);
void ecore_sheap_destroy(Ecore_Sheap *heap);
int ecore_sheap_init(Ecore_Sheap *heap, Ecore_Compare_Cb compare, int size);
int ecore_sheap_set_free_cb(Ecore_Sheap *heap, Ecore_Free_Cb free_func);
int ecore_sheap_insert(Ecore_Sheap *heap, void *data);
void *ecore_sheap_extract(Ecore_Sheap *heap);
void *ecore_sheap_extreme(Ecore_Sheap *heap);

View File

@ -63,16 +63,38 @@ int ecore_sheap_init(Ecore_Sheap *heap, Ecore_Compare_Cb compare, int size)
*/
void ecore_sheap_destroy(Ecore_Sheap *heap)
{
int i;
CHECK_PARAM_POINTER("heap", heap);
/*
* FIXME: Need to setup destructor callbacks for this class.
* Free data in heap
*/
if (heap->free_func)
for (i = 0; i < heap->size; i++)
heap->free_func(heap->data[i]);
FREE(heap->data);
FREE(heap);
}
/**
* Set the function for freeing data.
* @param heap The heap that will use this function when nodes are
* destroyed.
* @param free_func The function that will free the key data.
* @return @c TRUE on successful set, @c FALSE otherwise.
*/
int ecore_sheap_set_free_cb(Ecore_Sheap *heap, Ecore_Free_Cb free_func)
{
CHECK_PARAM_POINTER_RETURN("heap", heap, FALSE);
heap->free_func = free_func;
return TRUE;
}
/**
* Insert new data into the heap.
* @param heap The heap to insert @a data.
@ -215,7 +237,7 @@ int ecore_sheap_change(Ecore_Sheap *heap, void *item, void *newval)
CHECK_PARAM_POINTER_RETURN("heap", heap, FALSE);
for (i = 0; i < heap->size && heap->compare(heap->data[i], item); heap++);
for (i = 0; i < heap->size && heap->compare(heap->data[i], item); i++);
if (i < heap->size)
heap->data[i] = newval;

View File

@ -1454,8 +1454,9 @@ ecore_config_init_global(char *name)
int
ecore_config_init(char *name)
{
char *path;
Ecore_Config_Prop *list;
char *path;
Ecore_Config_Prop *list;
Ecore_Config_Bundle *temp;
_ecore_config_system_init_no_load();
__ecore_config_app_name = strdup(name);
@ -1463,11 +1464,12 @@ ecore_config_init(char *name)
if (!__ecore_config_server_local)
return ECORE_CONFIG_ERR_FAIL;
/* FIXME should free __ecore_config_bundle_local */
temp = __ecore_config_bundle_local;
list = __ecore_config_bundle_local->data;
__ecore_config_bundle_local =
ecore_config_bundle_new(__ecore_config_server_local, "config");
__ecore_config_bundle_local->data = list;
free(temp);
path = ecore_config_theme_default_path_get();
ecore_config_string_default("/e/themes/search_path", path);