Format to 'E' style.

Note: No functional changes, only formatting.


SVN revision: 23553
This commit is contained in:
Christopher Michael 2006-06-23 06:43:00 +00:00
parent 20f3183f49
commit 22b2d73375
5 changed files with 854 additions and 771 deletions

View File

@ -1,7 +1,7 @@
#ifndef WIN32
#include <dlfcn.h>
#include "ecore_private.h"
#include "Ecore_Data.h"
# include <dlfcn.h>
# include "ecore_private.h"
# include "Ecore_Data.h"
static Ecore_List *loaded_plugins = NULL;
@ -22,44 +22,44 @@ static Ecore_List *loaded_plugins = NULL;
EAPI Ecore_Plugin *
ecore_plugin_load(int group_id, char *plugin_name)
{
char *path;
char temp[PATH_MAX];
char *path;
char temp[PATH_MAX];
Ecore_Plugin *plugin;
void *handle = NULL;
Ecore_Plugin *plugin;
void *handle = NULL;
CHECK_PARAM_POINTER_RETURN("plugin_name", plugin_name, NULL);
CHECK_PARAM_POINTER_RETURN("plugin_name", plugin_name, NULL);
snprintf(temp, PATH_MAX, "%s.so", plugin_name);
path = ecore_path_group_find(group_id, temp);
if (!path)
return NULL;
snprintf(temp, PATH_MAX, "%s.so", plugin_name);
path = ecore_path_group_find(group_id, temp);
if (!path)
return NULL;
handle = dlopen(path, RTLD_LAZY);
if (!handle)
return NULL;
handle = dlopen(path, RTLD_LAZY);
if (!handle)
return NULL;
/*
* Allocate the new plugin and initialize it's fields
*/
plugin = malloc(sizeof(Ecore_Plugin));
memset(plugin, 0, sizeof(Ecore_Plugin));
/*
* Allocate the new plugin and initialize it's fields
*/
plugin = malloc(sizeof(Ecore_Plugin));
memset(plugin, 0, sizeof(Ecore_Plugin));
plugin->group = group_id;
plugin->name = strdup(plugin_name);
plugin->handle = handle;
plugin->group = group_id;
plugin->name = strdup(plugin_name);
plugin->handle = handle;
/*
* Now add it to the list of the groups loaded plugins
*/
if (!loaded_plugins)
loaded_plugins = ecore_list_new();
/*
* Now add it to the list of the groups loaded plugins
*/
if (!loaded_plugins)
loaded_plugins = ecore_list_new();
ecore_list_append(loaded_plugins, plugin);
ecore_list_append(loaded_plugins, plugin);
FREE(path);
FREE(path);
return plugin;
return plugin;
}
/**
@ -68,20 +68,20 @@ ecore_plugin_load(int group_id, char *plugin_name)
* @ingroup Ecore_Plugin
*/
EAPI void
ecore_plugin_unload(Ecore_Plugin * plugin)
ecore_plugin_unload(Ecore_Plugin *plugin)
{
CHECK_PARAM_POINTER("plugin", plugin);
CHECK_PARAM_POINTER("plugin", plugin);
if (!plugin->handle)
return;
if (!plugin->handle)
return;
if (ecore_list_goto(loaded_plugins, plugin))
ecore_list_remove(loaded_plugins);
if (ecore_list_goto(loaded_plugins, plugin))
ecore_list_remove(loaded_plugins);
dlclose(plugin->handle);
dlclose(plugin->handle);
FREE(plugin->name);
FREE(plugin);
FREE(plugin->name);
FREE(plugin);
}
/*
@ -92,18 +92,18 @@ ecore_plugin_unload(Ecore_Plugin * plugin)
* @ingroup Ecore_Plugin
*/
EAPI void *
ecore_plugin_call(Ecore_Plugin * plugin, char *symbol_name)
ecore_plugin_call(Ecore_Plugin *plugin, char *symbol_name)
{
void *ret;
void *ret;
CHECK_PARAM_POINTER_RETURN("plugin", plugin, NULL);
CHECK_PARAM_POINTER_RETURN("symbol_name", symbol_name, NULL);
CHECK_PARAM_POINTER_RETURN("plugin", plugin, NULL);
CHECK_PARAM_POINTER_RETURN("symbol_name", symbol_name, NULL);
if (!plugin->handle)
return NULL;
if (!plugin->handle)
return NULL;
ret = dlsym(plugin->handle, symbol_name);
ret = dlsym(plugin->handle, symbol_name);
return ret;
return ret;
}
#endif

View File

@ -18,21 +18,23 @@ static void _ecore_sheap_update_data(Ecore_Sheap *heap);
* @return A pointer to the newly allocated binary heap on success, NULL on
* failure.
*/
EAPI Ecore_Sheap *ecore_sheap_new(Ecore_Compare_Cb compare, int size)
EAPI Ecore_Sheap *
ecore_sheap_new(Ecore_Compare_Cb compare, int size)
{
Ecore_Sheap *heap = NULL;
Ecore_Sheap *heap = NULL;
heap = (Ecore_Sheap *)malloc(sizeof(Ecore_Sheap));
if (!heap)
return NULL;
memset(heap, 0, sizeof(Ecore_Sheap));
heap = (Ecore_Sheap *)malloc(sizeof(Ecore_Sheap));
if (!heap)
return NULL;
memset(heap, 0, sizeof(Ecore_Sheap));
if (!ecore_sheap_init(heap, compare, size)) {
FREE(heap);
return NULL;
}
if (!ecore_sheap_init(heap, compare, size))
{
FREE(heap);
return NULL;
}
return heap;
return heap;
}
/**
@ -42,23 +44,24 @@ EAPI Ecore_Sheap *ecore_sheap_new(Ecore_Compare_Cb compare, int size)
* @param size The number of elements to allow in the heap
* @return TRUE on success, FALSE on failure
*/
EAPI int ecore_sheap_init(Ecore_Sheap *heap, Ecore_Compare_Cb compare, int size)
EAPI int
ecore_sheap_init(Ecore_Sheap *heap, Ecore_Compare_Cb compare, int size)
{
CHECK_PARAM_POINTER_RETURN("heap", heap, FALSE);
CHECK_PARAM_POINTER_RETURN("heap", heap, FALSE);
heap->space = size;
if (!compare)
heap->compare = ecore_direct_compare;
else
heap->compare = compare;
heap->order = ECORE_SHEAP_MIN;
heap->space = size;
if (!compare)
heap->compare = ecore_direct_compare;
else
heap->compare = compare;
heap->order = ECORE_SHEAP_MIN;
heap->data = (void **)malloc(heap->space * sizeof(void *));
if (!heap->data)
return FALSE;
memset(heap->data, 0, heap->space * sizeof(void *));
heap->data = (void **)malloc(heap->space * sizeof(void *));
if (!heap->data)
return FALSE;
memset(heap->data, 0, heap->space * sizeof(void *));
return TRUE;
return TRUE;
}
/**
@ -69,22 +72,23 @@ EAPI int ecore_sheap_init(Ecore_Sheap *heap, Ecore_Compare_Cb compare, int size)
*
* @param heap The heap to be freed
*/
EAPI void ecore_sheap_destroy(Ecore_Sheap *heap)
EAPI void
ecore_sheap_destroy(Ecore_Sheap *heap)
{
int i;
int i;
CHECK_PARAM_POINTER("heap", heap);
CHECK_PARAM_POINTER("heap", heap);
/*
* Free data in heap
*/
if (heap->free_func)
for (i = 0; i < heap->size; i++)
heap->free_func(heap->data[i]);
/*
* 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->data);
FREE(heap);
FREE(heap);
}
/**
@ -94,13 +98,14 @@ EAPI void ecore_sheap_destroy(Ecore_Sheap *heap)
* @param free_func The function that will free the key data.
* @return @c TRUE on successful set, @c FALSE otherwise.
*/
EAPI int ecore_sheap_set_free_cb(Ecore_Sheap *heap, Ecore_Free_Cb free_func)
EAPI int
ecore_sheap_set_free_cb(Ecore_Sheap *heap, Ecore_Free_Cb free_func)
{
CHECK_PARAM_POINTER_RETURN("heap", heap, FALSE);
CHECK_PARAM_POINTER_RETURN("heap", heap, FALSE);
heap->free_func = free_func;
heap->free_func = free_func;
return TRUE;
return TRUE;
}
/**
@ -110,85 +115,90 @@ EAPI int ecore_sheap_set_free_cb(Ecore_Sheap *heap, Ecore_Free_Cb free_func)
* @return TRUE on success, NULL on failure. Increases the size of the heap if
* it becomes larger than available space.
*/
EAPI int ecore_sheap_insert(Ecore_Sheap *heap, void *data)
EAPI int
ecore_sheap_insert(Ecore_Sheap *heap, void *data)
{
int i;
void *temp;
int parent;
int position;
int i;
void *temp;
int parent;
int position;
CHECK_PARAM_POINTER_RETURN("heap", heap, FALSE);
CHECK_PARAM_POINTER_RETURN("heap", heap, FALSE);
/*
* Increase the size of the allocated data area if there isn't enough
* space available to add this data
*/
if (heap->size >= heap->space)
return FALSE;
/*
* Increase the size of the allocated data area if there isn't enough
* space available to add this data
*/
if (heap->size >= heap->space)
return FALSE;
heap->sorted = FALSE;
heap->sorted = FALSE;
/*
* Place the data at the end of the heap initially. Then determine the
* parent and position in the array of it's parent.
*/
heap->data[heap->size] = data;
position = heap->size;
heap->size++;
i = heap->size;
parent = PARENT(i) - 1;
/*
* Place the data at the end of the heap initially. Then determine the
* parent and position in the array of it's parent.
*/
heap->data[heap->size] = data;
position = heap->size;
heap->size++;
i = heap->size;
parent = PARENT(i) - 1;
/*
* Check the order of the heap to decide where to place the inserted
* data. The loop is placed inside the if statement to reduce the
* number of branching decisions that must be predicted.
*/
if (heap->order == ECORE_SHEAP_MIN) {
while ((position > 0) && heap->compare(heap->data[parent],
heap->data[position]) > 0) {
/*
* Check the order of the heap to decide where to place the inserted
* data. The loop is placed inside the if statement to reduce the
* number of branching decisions that must be predicted.
*/
if (heap->order == ECORE_SHEAP_MIN)
{
while ((position > 0) && heap->compare(heap->data[parent],
heap->data[position]) > 0)
{
/*
* Swap the data with it's parents to move it up in
* the heap.
*/
temp = heap->data[position];
heap->data[position] = heap->data[parent];
heap->data[parent] = temp;
/*
* Swap the data with it's parents to move it up in
* the heap.
*/
temp = heap->data[position];
heap->data[position] = heap->data[parent];
heap->data[parent] = temp;
/*
* Now determine the new position for the next
* iteration of the loop, as well as it's parents
* position.
*/
i = PARENT(i);
position = i - 1;
parent = PARENT(i) - 1;
}
}
else {
while ((position > 0) && heap->compare(heap->data[parent],
heap->data[position]) < 0) {
/*
* Now determine the new position for the next
* iteration of the loop, as well as it's parents
* position.
*/
i = PARENT(i);
position = i - 1;
parent = PARENT(i) - 1;
}
}
else
{
while ((position > 0) && heap->compare(heap->data[parent],
heap->data[position]) < 0)
{
/*
* Swap the data with it's parents to move it up in
* the heap.
*/
temp = heap->data[position];
heap->data[position] = heap->data[PARENT(i) - 1];
heap->data[PARENT(i) - 1] = temp;
/*
* Swap the data with it's parents to move it up in
* the heap.
*/
temp = heap->data[position];
heap->data[position] = heap->data[PARENT(i) - 1];
heap->data[PARENT(i) - 1] = temp;
/*
* Now determine the new position for the next
* iteration of the loop, as well as it's parents
* position.
*/
i = PARENT(i);
position = i - 1;
parent = PARENT(i) - 1;
}
}
/*
* Now determine the new position for the next
* iteration of the loop, as well as it's parents
* position.
*/
i = PARENT(i);
position = i - 1;
parent = PARENT(i) - 1;
}
}
return TRUE;
return TRUE;
}
/**
@ -198,22 +208,23 @@ EAPI int ecore_sheap_insert(Ecore_Sheap *heap, void *data)
* @note The extract function maintains the heap properties after the
* extract.
*/
EAPI void *ecore_sheap_extract(Ecore_Sheap *heap)
EAPI void *
ecore_sheap_extract(Ecore_Sheap *heap)
{
void *extreme;
void *extreme;
if (heap->size < 1)
return NULL;
if (heap->size < 1)
return NULL;
heap->sorted = FALSE;
heap->sorted = FALSE;
extreme = heap->data[0];
heap->size--;
heap->data[0] = heap->data[heap->size];
extreme = heap->data[0];
heap->size--;
heap->data[0] = heap->data[heap->size];
_ecore_sheap_heapify(heap, 1);
_ecore_sheap_heapify(heap, 1);
return extreme;
return extreme;
}
/**
@ -222,12 +233,13 @@ EAPI void *ecore_sheap_extract(Ecore_Sheap *heap)
* @return The top item of the heap on success, NULL on failure.
* @note The function does not alter the heap.
*/
EAPI void *ecore_sheap_extreme(Ecore_Sheap *heap)
EAPI void *
ecore_sheap_extreme(Ecore_Sheap *heap)
{
if (heap->size < 1)
return NULL;
if (heap->size < 1)
return NULL;
return heap->data[0];
return heap->data[0];
}
/**
@ -239,25 +251,26 @@ EAPI void *ecore_sheap_extreme(Ecore_Sheap *heap)
* @note The heap does not free the old data since it must be passed
* in, so the caller can perform the free if desired.
*/
EAPI int ecore_sheap_change(Ecore_Sheap *heap, void *item, void *newval)
EAPI int
ecore_sheap_change(Ecore_Sheap *heap, void *item, void *newval)
{
int i;
int i;
CHECK_PARAM_POINTER_RETURN("heap", heap, FALSE);
CHECK_PARAM_POINTER_RETURN("heap", heap, FALSE);
for (i = 0; i < heap->size && heap->compare(heap->data[i], item); i++);
for (i = 0; i < heap->size && heap->compare(heap->data[i], item); i++);
if (i < heap->size)
heap->data[i] = newval;
else
return FALSE;
if (i < heap->size)
heap->data[i] = newval;
else
return FALSE;
/*
* FIXME: This is not the correct procedure when a change occurs.
*/
_ecore_sheap_heapify(heap, 1);
/*
* FIXME: This is not the correct procedure when a change occurs.
*/
_ecore_sheap_heapify(heap, 1);
return TRUE;
return TRUE;
}
/**
@ -265,39 +278,41 @@ EAPI int ecore_sheap_change(Ecore_Sheap *heap, void *item, void *newval)
* @param heap The heap to change comparison function
* @param compare The new function for comparing nodes
* @return TRUE on success, FALSE on failure.
*
*
* The comparison function is changed to @compare and the heap is heapified
* by the new comparison.
*/
EAPI int ecore_sheap_set_compare(Ecore_Sheap *heap, Ecore_Compare_Cb compare)
EAPI int
ecore_sheap_set_compare(Ecore_Sheap *heap, Ecore_Compare_Cb compare)
{
CHECK_PARAM_POINTER_RETURN("heap", heap, FALSE);
CHECK_PARAM_POINTER_RETURN("heap", heap, FALSE);
if (!compare)
heap->compare = ecore_direct_compare;
else
heap->compare = compare;
if (!compare)
heap->compare = ecore_direct_compare;
else
heap->compare = compare;
_ecore_sheap_update_data(heap);
_ecore_sheap_update_data(heap);
return TRUE;
return TRUE;
}
/**
* Change the order of the heap
* @param heap The heap to change the order
* @param order The new order of the heap
*
*
* Changes the heap order of @heap and re-heapifies the data to this new
* order. The default order is a min heap.
*/
EAPI void ecore_sheap_set_order(Ecore_Sheap *heap, char order)
EAPI void
ecore_sheap_set_order(Ecore_Sheap *heap, char order)
{
CHECK_PARAM_POINTER("heap", heap);
CHECK_PARAM_POINTER("heap", heap);
heap->order = order;
heap->order = order;
_ecore_sheap_update_data(heap);
_ecore_sheap_update_data(heap);
}
/**
@ -307,29 +322,30 @@ EAPI void ecore_sheap_set_order(Ecore_Sheap *heap, char order)
* Sorts the data in the heap into the order that is used for the heap's
* data.
*/
EAPI void ecore_sheap_sort(Ecore_Sheap *heap)
EAPI void
ecore_sheap_sort(Ecore_Sheap *heap)
{
int i = 0;
void **new_data;
int i = 0;
void **new_data;
CHECK_PARAM_POINTER("heap", heap);
CHECK_PARAM_POINTER("heap", heap);
new_data = (void **)malloc(heap->size * sizeof(void *));
new_data = (void **)malloc(heap->size * sizeof(void *));
/*
* Extract the heap and insert into the new data array in order.
*/
while (heap->size > 0)
new_data[i++] = ecore_sheap_extract(heap);
/*
* Extract the heap and insert into the new data array in order.
*/
while (heap->size > 0)
new_data[i++] = ecore_sheap_extract(heap);
/*
* Free the old data array and update the heap with the new data, also
* mark as sorted.
*/
FREE(heap->data);
heap->data = new_data;
heap->size = i;
heap->sorted = TRUE;
/*
* Free the old data array and update the heap with the new data, also
* mark as sorted.
*/
FREE(heap->data);
heap->data = new_data;
heap->size = i;
heap->sorted = TRUE;
}
/*
@ -340,18 +356,19 @@ EAPI void ecore_sheap_sort(Ecore_Sheap *heap)
* NULL on failure.
* @note The data is guaranteed to be in sorted order.
*/
EAPI inline void *ecore_sheap_item(Ecore_Sheap *heap, int i)
EAPI inline void *
ecore_sheap_item(Ecore_Sheap *heap, int i)
{
if (i >= heap->size)
return NULL;
if (i >= heap->size)
return NULL;
/*
* Make sure the data is sorted so we return the correct value.
*/
if (!heap->sorted)
ecore_sheap_sort(heap);
/*
* Make sure the data is sorted so we return the correct value.
*/
if (!heap->sorted)
ecore_sheap_sort(heap);
return heap->data[i];
return heap->data[i];
}
/*
@ -359,69 +376,71 @@ EAPI inline void *ecore_sheap_item(Ecore_Sheap *heap, int i)
* @param heap The heap to regain heap properties
* @param i The position to start heapifying
*/
static void _ecore_sheap_heapify(Ecore_Sheap *heap, int i)
static void
_ecore_sheap_heapify(Ecore_Sheap *heap, int i)
{
int extreme;
int left = LEFT(i);
int right = RIGHT(i);
int extreme;
int left = LEFT(i);
int right = RIGHT(i);
if (heap->order == ECORE_SHEAP_MIN) {
if (left <= heap->size && heap->compare(heap->data[left - 1],
heap->data[i - 1]) < 0)
extreme = left;
else
extreme = i;
if (heap->order == ECORE_SHEAP_MIN)
{
if (left <= heap->size && heap->compare(heap->data[left - 1],
heap->data[i - 1]) < 0)
extreme = left;
else
extreme = i;
if (right <= heap->size && heap->compare(heap->data[right - 1],
heap->data[extreme - 1]) < 0)
extreme = right;
}
else {
if (left <= heap->size && heap->compare(heap->data[left - 1],
heap->data[i - 1]) > 0)
extreme = left;
else
extreme = i;
if (right <= heap->size && heap->compare(heap->data[right - 1],
heap->data[extreme - 1]) < 0)
extreme = right;
}
else
{
if (left <= heap->size && heap->compare(heap->data[left - 1],
heap->data[i - 1]) > 0)
extreme = left;
else
extreme = i;
if (right <= heap->size && heap->compare(heap->data[right - 1],
heap->data[extreme - 1]) > 0)
extreme = right;
}
if (right <= heap->size && heap->compare(heap->data[right - 1],
heap->data[extreme - 1]) > 0)
extreme = right;
}
/*
* If the data needs to be swapped down the heap, recurse on
* heapifying it's new placement.
*/
if (extreme != i) {
void *temp;
/*
* If the data needs to be swapped down the heap, recurse on
* heapifying it's new placement.
*/
if (extreme != i)
{
void *temp;
temp = heap->data[extreme - 1];
heap->data[extreme - 1] = heap->data[i - 1];
heap->data[i - 1] = temp;
temp = heap->data[extreme - 1];
heap->data[extreme - 1] = heap->data[i - 1];
heap->data[i - 1] = temp;
_ecore_sheap_heapify(heap, extreme);
}
_ecore_sheap_heapify(heap, extreme);
}
}
static void _ecore_sheap_update_data(Ecore_Sheap *heap)
static void
_ecore_sheap_update_data(Ecore_Sheap *heap)
{
int i, old_size;
void **data;
int i, old_size;
void **data;
/*
* Track the old values from the heap
*/
old_size = heap->size;
data = heap->data;
/*
* Track the old values from the heap
*/
old_size = heap->size;
data = heap->data;
/*
*
*/
heap->size = 0;
heap->data = malloc(heap->space * sizeof(void *));
heap->size = 0;
heap->data = malloc(heap->space * sizeof(void *));
for (i = 0; i < old_size; i++)
ecore_sheap_insert(heap, data[i]);
for (i = 0; i < old_size; i++)
ecore_sheap_insert(heap, data[i]);
FREE(data);
FREE(data);
}

View File

@ -17,21 +17,23 @@ static int ecore_string_init_count = 0;
* Initialize the ecore string internal structure.
* @return Zero on failure, non-zero on successful initialization.
*/
EAPI int ecore_string_init()
EAPI int
ecore_string_init()
{
/*
* No strings have been loaded at this point, so create the hash
* table for storing string info for later.
*/
if (!ecore_string_init_count) {
ecore_strings = ecore_hash_new(ecore_str_hash, ecore_str_compare);
if (!ecore_strings)
return 0;
ecore_hash_set_free_value(ecore_strings, ecore_string_free_cb);
}
ecore_string_init_count++;
/*
* No strings have been loaded at this point, so create the hash
* table for storing string info for later.
*/
if (!ecore_string_init_count)
{
ecore_strings = ecore_hash_new(ecore_str_hash, ecore_str_compare);
if (!ecore_strings)
return 0;
ecore_hash_set_free_value(ecore_strings, ecore_string_free_cb);
}
ecore_string_init_count++;
return 1;
return 1;
}
/**
@ -41,78 +43,85 @@ EAPI int ecore_string_init()
* @c NULL on failure.
* @ingroup Ecore_String_Group
*/
EAPI const char *ecore_string_instance(char *string)
EAPI const char *
ecore_string_instance(char *string)
{
Ecore_String *str;
Ecore_String *str;
CHECK_PARAM_POINTER_RETURN("string", string, NULL);
CHECK_PARAM_POINTER_RETURN("string", string, NULL);
/*
* Check for a previous instance of the string, if not found, create
* it.
*/
str = ecore_hash_get(ecore_strings, string);
if (!str)
{
/*
* Check for a previous instance of the string, if not found, create
* it.
* Allocate and initialize a new string reference.
*/
str = ecore_hash_get(ecore_strings, string);
if (!str) {
str = (Ecore_String *)malloc(sizeof(Ecore_String));
/*
* Allocate and initialize a new string reference.
*/
str = (Ecore_String *)malloc(sizeof(Ecore_String));
str->string = strdup(string);
str->references = 0;
str->string = strdup(string);
str->references = 0;
ecore_hash_set(ecore_strings, str->string, str);
}
ecore_hash_set(ecore_strings, str->string, str);
}
str->references++;
str->references++;
return str->string;
return str->string;
}
/**
* Notes that the given string has lost an instance.
*
*
* It will free the string if no other instances are left.
*
* @param string The given string.
* @ingroup Ecore_String_Group
*/
EAPI void ecore_string_release(const char *string)
EAPI void
ecore_string_release(const char *string)
{
Ecore_String *str;
Ecore_String *str;
CHECK_PARAM_POINTER("string", string);
CHECK_PARAM_POINTER("string", string);
str = ecore_hash_get(ecore_strings, (char *)string);
if (!str)
return;
str = ecore_hash_get(ecore_strings, (char *)string);
if (!str)
return;
str->references--;
if (str->references < 1) {
ecore_hash_remove(ecore_strings, (char *)string);
FREE(str->string);
FREE(str);
}
str->references--;
if (str->references < 1)
{
ecore_hash_remove(ecore_strings, (char *)string);
FREE(str->string);
FREE(str);
}
}
/**
* Shutdown the ecore string internal structures
*/
EAPI void ecore_string_shutdown()
EAPI void
ecore_string_shutdown()
{
--ecore_string_init_count;
if (!ecore_string_init_count) {
ecore_hash_destroy(ecore_strings);
ecore_strings = NULL;
}
--ecore_string_init_count;
if (!ecore_string_init_count)
{
ecore_hash_destroy(ecore_strings);
ecore_strings = NULL;
}
}
static void ecore_string_free_cb(void *data)
static void
ecore_string_free_cb(void *data)
{
Ecore_String *str;
Ecore_String *str;
str = data;
FREE(str->string);
FREE(str);
str = data;
FREE(str->string);
FREE(str);
}

File diff suppressed because it is too large Load Diff

View File

@ -28,20 +28,23 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "Ecore_Data.h"
#include "ecore_private.h"
EAPI const unsigned int ecore_prime_table[] = { 17, 31, 61, 127, 257, 509, 1021,
2053, 4093, 8191, 16381, 32771, 65537, 131071, 262147, 524287, 1048573,
2097143, 4194301, 8388617, 16777213
EAPI const unsigned int ecore_prime_table[] =
{
17, 31, 61, 127, 257, 509, 1021,
2053, 4093, 8191, 16381, 32771, 65537, 131071, 262147, 524287, 1048573,
2097143, 4194301, 8388617, 16777213
};
inline void ecore_print_warning(const char *function, const char *sparam)
inline void
ecore_print_warning(const char *function, const char *sparam)
{
fprintf(stderr, "***** Developer Warning ***** :\n"
"\tThis program is calling:\n\n"
"\t%s();\n\n"
"\tWith the parameter:\n\n"
"\t%s\n\n"
"\tbeing NULL. Please fix your program.\n", function, sparam);
fflush(stderr);
fprintf(stderr, "***** Developer Warning ***** :\n"
"\tThis program is calling:\n\n"
"\t%s();\n\n"
"\tWith the parameter:\n\n"
"\t%s\n\n"
"\tbeing NULL. Please fix your program.\n", function, sparam);
fflush(stderr);
}
/**
@ -49,9 +52,10 @@ inline void ecore_print_warning(const char *function, const char *sparam)
* @param key The key to return compute a hash value
* @return The key cast to an unsigned int.
*/
EAPI unsigned int ecore_direct_hash(void *key)
EAPI unsigned int
ecore_direct_hash(void *key)
{
return ((unsigned int) key);
return ((unsigned int) key);
}
/**
@ -59,21 +63,23 @@ EAPI unsigned int ecore_direct_hash(void *key)
* @param key A pointer to the string to compute a hash value
* @return A computed hash value for @a key.
*/
EAPI unsigned int ecore_str_hash(void *key)
EAPI unsigned int
ecore_str_hash(void *key)
{
int i;
unsigned int value = 0;
char *k = (char *) key;
int i;
unsigned int value = 0;
char *k = (char *) key;
if (!k)
return 0;
if (!k)
return 0;
for (i = 0; k[i] != '\0'; i++) {
value ^= ((unsigned int) k[i] << ((i * 5) %
(sizeof(unsigned int) * 8)));
}
for (i = 0; k[i] != '\0'; i++)
{
value ^= ((unsigned int) k[i] << ((i * 5) %
(sizeof(unsigned int) * 8)));
}
return value;
return value;
}
/**
@ -82,20 +88,21 @@ EAPI unsigned int ecore_str_hash(void *key)
* @param key2 The second key to compare
* @return A strcmp style value to indicate the larger key
*/
EAPI int ecore_direct_compare(void *key1, void *key2)
EAPI int
ecore_direct_compare(void *key1, void *key2)
{
unsigned int k1, k2;
unsigned int k1, k2;
k1 = (unsigned int) key1;
k2 = (unsigned int) key2;
k1 = (unsigned int) key1;
k2 = (unsigned int) key2;
if (k1 > k2)
return 1;
if (k1 > k2)
return 1;
if (k1 < k2)
return -1;
if (k1 < k2)
return -1;
return 0;
return 0;
}
/**
@ -104,17 +111,18 @@ EAPI int ecore_direct_compare(void *key1, void *key2)
* @param key2 The second key to compare
* @return A strcmp style value to indicate the larger key
*/
EAPI int ecore_str_compare(void *key1, void *key2)
EAPI int
ecore_str_compare(void *key1, void *key2)
{
char *k1, *k2;
char *k1, *k2;
if (!key1 || !key2)
return ecore_direct_compare(key1, key2);
else if (key1 == key2)
return 0;
if (!key1 || !key2)
return ecore_direct_compare(key1, key2);
else if (key1 == key2)
return 0;
k1 = (char *) key1;
k2 = (char *) key2;
k1 = (char *) key1;
k2 = (char *) key2;
return strcmp(k1, k2);
return strcmp(k1, k2);
}