commit f8c543b955fb0e7dde34d6be06a2cd966b2f7087
Author:     Roberto E. Vargas Caballero <k...@shike2.com>
AuthorDate: Fri Oct 7 09:40:30 2016 +0200
Commit:     Roberto E. Vargas Caballero <k...@shike2.com>
CommitDate: Fri Oct 7 09:45:42 2016 +0200

    [cc1] Remove duptype()
    
    This function was created only to avoid exporting newid(),
    but the solution was worse than the original problem.

diff --git a/cc1/cc1.h b/cc1/cc1.h
index 83d1179..9ded21e 100644
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -368,6 +368,7 @@ extern void killsym(Symbol *sym);
 extern Symbol *newlabel(void);
 extern void keywords(struct keyword *key, int ns);
 extern Symbol *newstring(char *s, size_t len);
+extern unsigned newid(void);
 
 /* stmt.c */
 extern void compound(Symbol *lbreak, Symbol *lcont, Switch *sw);
diff --git a/cc1/symbol.c b/cc1/symbol.c
index 7d25b33..9eea01c 100644
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
@@ -122,7 +122,7 @@ popctx(void)
        head = sym;
 }
 
-static unsigned short
+unsigned
 newid(void)
 {
        unsigned short id;
@@ -135,16 +135,6 @@ newid(void)
        return id;
 }
 
-Type *
-duptype(Type *base)
-{
-       Type *tp = xmalloc(sizeof(*tp));
-
-       *tp = *base;
-       tp->id = newid();
-       return tp;
-}
-
 static Symbol *
 allocsym(int ns, char *name)
 {
diff --git a/cc1/types.c b/cc1/types.c
index 170e4a8..d9c28e5 100644
--- a/cc1/types.c
+++ b/cc1/types.c
@@ -308,8 +308,9 @@ mktype(Type *tp, int op, TINT nelem, Type *pars[])
                }
        }
 
-       typesize(&type);
-       bp = duptype(&type);
+       bp = xmalloc(sizeof(*bp));
+       *bp = type;
+       bp->id = newid();
        bp->next = *tbl;
        return *tbl = bp;
 }

Reply via email to