[hackers] [scc] Remove the difference between local and global id || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Thu, 24 Sep 2015 23:14:24 +0200 (CEST)

commit 742a008857ece4651a448d49954a08383dc714fc
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Sep 24 23:11:33 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Sep 24 23:11:33 2015 +0200

    Remove the difference between local and global id
    
    These difference were created long time ago to have different tables
    for locals and global identifiers, but this was a stupid solution.
    We are using this id now only how an identifier to find symbols
    in a common hash, so this difference was creating collisions in the
    table.

diff --git a/cc1/symbol.c b/cc1/symbol.c
index e14f1a4..65a00a6 100644
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
_AT_@ -12,8 +12,7 @@
 #define NR_SYM_HASH 64
 
 unsigned curctx;
-static unsigned short localcnt;
-static unsigned short globalcnt;
+static unsigned short counterid;
 
 static Symbol *head, *labels;
 static Symbol *htab[NR_SYM_HASH];
_AT_@ -105,7 +104,6 @@ popctx(void)
         short f;
 
         if (--curctx == GLOBALCTX) {
- localcnt = 0;
                 for (sym = labels; sym; sym = next) {
                         next = sym->next;
                         killsym(sym);
_AT_@ -125,7 +123,7 @@ newid(void)
 {
         unsigned short id;
 
- id = (curctx) ? ++localcnt : ++globalcnt;
+ id = ++counterid;
         if (id == 0) {
                 die("Overflow in %s identifiers",
                     (curctx) ? "internal" : "external");
_AT_@ -375,6 +373,6 @@ ikeywords(void)
          * will make faster some operations. There is no problem of memory
          * leakeage because this memory is not ever freed
          */
- globalcnt = 0;
+ counterid = 0;
         head = NULL;
 }
Received on Thu Sep 24 2015 - 23:14:24 CEST

This archive was generated by hypermail 2.3.0 : Thu Sep 24 2015 - 23:24:11 CEST