diff --git a/legacy/eet/src/lib/Eet.h b/legacy/eet/src/lib/Eet.h index 848b97029b..c5c89673e6 100644 --- a/legacy/eet/src/lib/Eet.h +++ b/legacy/eet/src/lib/Eet.h @@ -478,7 +478,7 @@ extern "C" { /** * Create a new empty data structure descriptor. - * @param name The string name of this data structure. + * @param name The string name of this data structure (most be a global constant and never change). * @param size The size of the struct (in bytes). * @param func_list_next The function to get the next list node. * @param func_list_append The function to append a member to a list. @@ -647,7 +647,7 @@ extern "C" { * @endcode * */ - EAPI Eet_Data_Descriptor *eet_data_descriptor_new(char *name, int size, void *(*func_list_next) (void *l), void *(*func_list_append) (void *l, void *d), void *(*func_list_data) (void *l), void *(*func_list_free) (void *l), void (*func_hash_foreach) (void *h, int (*func) (void *h, const char *k, void *dt, void *fdt), void *fdt), void *(*func_hash_add) (void *h, const char *k, void *d), void (*func_hash_free) (void *h)); + EAPI Eet_Data_Descriptor *eet_data_descriptor_new(const char *name, int size, void *(*func_list_next) (void *l), void *(*func_list_append) (void *l, void *d), void *(*func_list_data) (void *l), void *(*func_list_free) (void *l), void (*func_hash_foreach) (void *h, int (*func) (void *h, const char *k, void *dt, void *fdt), void *fdt), void *(*func_hash_add) (void *h, const char *k, void *d), void (*func_hash_free) (void *h)); /** * This function frees a data descriptor when it is not needed anymore. @@ -669,7 +669,7 @@ extern "C" { * thus is not documented. * */ - EAPI void eet_data_descriptor_element_add(Eet_Data_Descriptor *edd, char *name, int type, int group_type, int offset, int count, char *counter_name, Eet_Data_Descriptor *subtype); + EAPI void eet_data_descriptor_element_add(Eet_Data_Descriptor *edd, const char *name, int type, int group_type, int offset, int count, const char *counter_name, Eet_Data_Descriptor *subtype); /** * Read a data structure from an eet file and decodes it. @@ -767,7 +767,7 @@ extern "C" { * Add a basic data element to a data descriptor. * @param edd The data descriptor to add the type to. * @param struct_type The type of the struct. - * @param name The string name to use to encode/decode this member. + * @param name The string name to use to encode/decode this member (must be a constant global and never change). * @param member The struct member itself to be encoded. * @param type The type of the member to encode. * @@ -796,7 +796,7 @@ extern "C" { * Add a sub-element type to a data descriptor * @param edd The data descriptor to add the type to. * @param struct_type The type of the struct. - * @param name The string name to use to encode/decode this member. + * @param name The string name to use to encode/decode this member (must be a constant global and never change). * @param member The struct member itself to be encoded. * @param subtype The type of sub-type struct to add. * @@ -820,7 +820,7 @@ extern "C" { * Add a linked list type to a data descriptor * @param edd The data descriptor to add the type to. * @param struct_type The type of the struct. - * @param name The string name to use to encode/decode this member. + * @param name The string name to use to encode/decode this member (must be a constant global and never change). * @param member The struct member itself to be encoded. * @param subtype The type of linked list member to add. * diff --git a/legacy/eet/src/lib/eet_data.c b/legacy/eet/src/lib/eet_data.c index e9fbcd30d1..227cf01b62 100644 --- a/legacy/eet/src/lib/eet_data.c +++ b/legacy/eet/src/lib/eet_data.c @@ -97,8 +97,8 @@ struct _Eet_Data_Descriptor Eet_Data_Descriptor_Hash *buckets; } hash; } elements; - char *strings; - int strings_len; +// char *strings; +// int strings_len; }; struct _Eet_Data_Element @@ -695,7 +695,7 @@ _eet_descriptor_hash_find(Eet_Data_Descriptor *edd, char *name) /*---*/ Eet_Data_Descriptor * -eet_data_descriptor_new(char *name, +eet_data_descriptor_new(const char *name, int size, void *(*func_list_next) (void *l), void *(*func_list_append) (void *l, void *d), @@ -708,9 +708,13 @@ eet_data_descriptor_new(char *name, Eet_Data_Descriptor *edd; if (!name) return NULL; +/* edd = calloc(1, sizeof(Eet_Data_Descriptor) + strlen(name) + 1); edd->name = ((char *)edd) + sizeof(Eet_Data_Descriptor); strcpy(edd->name, name); + */ + edd = calloc(1, sizeof(Eet_Data_Descriptor)); + edd->name = name; edd->size = size; edd->func.list_next = func_list_next; edd->func.list_append = func_list_append; @@ -726,16 +730,17 @@ void eet_data_descriptor_free(Eet_Data_Descriptor *edd) { _eet_descriptor_hash_free(edd); - if (edd->strings) free(edd->strings); +// if (edd->strings) free(edd->strings); if (edd->elements.set) free(edd->elements.set); free(edd); } void -eet_data_descriptor_element_add(Eet_Data_Descriptor *edd, char *name, int type, +eet_data_descriptor_element_add(Eet_Data_Descriptor *edd, + const char *name, int type, int group_type, int offset, - int count, char *counter_name, + int count, const char *counter_name, Eet_Data_Descriptor *subtype) { Eet_Data_Element *ede; @@ -746,7 +751,7 @@ eet_data_descriptor_element_add(Eet_Data_Descriptor *edd, char *name, int type, edd->elements.set = realloc(edd->elements.set, edd->elements.num * sizeof(Eet_Data_Element)); if (!edd->elements.set) return; ede = &(edd->elements.set[edd->elements.num - 1]); - +/* l1 = strlen(name); p1 = edd->strings_len; if (counter_name) @@ -773,16 +778,23 @@ eet_data_descriptor_element_add(Eet_Data_Descriptor *edd, char *name, int type, } ede->name = edd->strings + p1; strcpy(ede->name, name); + */ + ede->name = name; + ede->type = type; ede->group_type = group_type; ede->offset = offset; ede->count = count; +/* if (counter_name) { ede->counter_name = edd->strings + p2; strcpy(ede->counter_name, counter_name); } else ede->counter_name = NULL; + */ + ede->counter_name = counter_name; + ede->subtype = subtype; }