[hackers] [scc] [cc1] Remove duptype() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 17 Oct 2016 10:46:00 +0200 (CEST)

commit f8c543b955fb0e7dde34d6be06a2cd966b2f7087
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Oct 7 09:40:30 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_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
_AT_@ -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
_AT_@ -122,7 +122,7 @@ popctx(void)
         head = sym;
 }
 
-static unsigned short
+unsigned
 newid(void)
 {
         unsigned short id;
_AT_@ -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
_AT_@ -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;
 }
Received on Mon Oct 17 2016 - 10:46:00 CEST

This archive was generated by hypermail 2.3.0 : Mon Oct 17 2016 - 10:48:15 CEST