You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2014/08/05 12:45:07 UTC

git commit: Remove OBJ_HEAD from ivars struct

Repository: lucy-clownfish
Updated Branches:
  refs/heads/master 706e3068b -> 71bdaae9b


Remove OBJ_HEAD from ivars struct

OBJ_HEAD is only needed once at the start of the object.

(This change was originally part of branch 'ivars_fixes', which I
abandoned.)


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/71bdaae9
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/71bdaae9
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/71bdaae9

Branch: refs/heads/master
Commit: 71bdaae9bc0428ebbbd20f6507a5007d858d9cea
Parents: 706e306
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Tue Aug 5 12:39:09 2014 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue Aug 5 12:41:19 2014 +0200

----------------------------------------------------------------------
 compiler/src/CFCBindClass.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/71bdaae9/compiler/src/CFCBindClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindClass.c b/compiler/src/CFCBindClass.c
index ebeb07d..86caeac 100644
--- a/compiler/src/CFCBindClass.c
+++ b/compiler/src/CFCBindClass.c
@@ -408,9 +408,12 @@ static char*
 S_struct_definition(CFCBindClass *self) {
     CFCClass *const client = self->client;
     const char *struct_sym;
+    char       *member_decs = CFCUtil_strdup("");
+
     const char *prefix = CFCClass_get_prefix(client);
     if (strcmp(prefix, "cfish_") == 0) {
         struct_sym = CFCClass_full_struct_sym(client);
+        member_decs = CFCUtil_cat(member_decs, "\n    CFISH_OBJ_HEAD", NULL);
     }
     else {
         struct_sym = CFCClass_full_ivars_struct(client);
@@ -430,16 +433,12 @@ S_struct_definition(CFCBindClass *self) {
 
     // Add all member variables declared by classes in this package.
     CFCVariable **member_vars = CFCClass_member_vars(client);
-    char *member_decs = CFCUtil_strdup("");
     for (int i = num_non_package_members; member_vars[i] != NULL; i++) {
         const char *member_dec = CFCVariable_local_declaration(member_vars[i]);
-        size_t needed = strlen(member_decs) + strlen(member_dec) + 10;
-        member_decs = (char*)REALLOCATE(member_decs, needed);
-        strcat(member_decs, "\n    ");
-        strcat(member_decs, member_dec);
+        member_decs = CFCUtil_cat(member_decs, "\n    ", member_dec, NULL);
     }
 
-    char pattern[] = "struct %s {\n    CFISH_OBJ_HEAD%s\n};\n";
+    char pattern[] = "struct %s {%s\n};\n";
     char *struct_def = CFCUtil_sprintf(pattern, struct_sym, member_decs);
 
     FREEMEM(member_decs);