Enlightenment CVS committal

Author  : raster
Project : e17
Module  : libs/eet

Dir     : e17/libs/eet/src/lib


Modified Files:
        Eet.h eet_data.c 


Log Message:


seriously - no one uses dynamic buffers for setting up an eet descriptor -
theyare fixed strings. so why strdup them? use them direct. they are in the
read-only segment already - keep them there! :)

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/eet/src/lib/Eet.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -3 -r1.26 -r1.27
--- Eet.h       3 Nov 2005 13:05:52 -0000       1.26
+++ Eet.h       27 Nov 2005 16:06:55 -0000      1.27
@@ -478,7 +478,7 @@
 
    /**
     * 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 @@
     * @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 @@
     * 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 @@
     * 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 @@
     * 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 @@
     * 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.
     *
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/eet/src/lib/eet_data.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -3 -r1.29 -r1.30
--- eet_data.c  27 Nov 2005 14:32:44 -0000      1.29
+++ eet_data.c  27 Nov 2005 16:06:55 -0000      1.30
@@ -97,8 +97,8 @@
         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_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 *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 @@
 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 @@
    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 @@
      }
    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;
 }
 




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to