static struct permts *perm_tail; /* end of perm. text storage */
static void init_block(union label *blk);
-static char *perm_copy(char *string1, char *string2);
+static char *perm_copy(const char *string);
static char *prevlabel;
if (prevlen+len >= IDLEN_MAX)
return NULL; /* Error... */
memcpy(label_str, prev, prevlen);
- memcpy(label_str+prevlen, label, len);
- label_str[len += prevlen] = '\0';
+ memcpy(label_str+prevlen, label, len+1);
label = label_str;
} else {
prev = "";
}
lfree->admin.movingon = BOGUS_VALUE;
- lfree->defn.label = perm_copy(prev, label);
+ lfree->defn.label = perm_copy(label);
lfree->defn.special = NULL;
lfree->defn.is_global = NOT_DEFINED_YET;
switch (lptr->defn.is_global & TYPE_MASK) {
case NOT_DEFINED_YET:
lptr->defn.is_global = GLOBAL_PLACEHOLDER;
- lptr->defn.special = special ? perm_copy(special, "") : NULL;
+ lptr->defn.special = special ? perm_copy(special) : NULL;
break;
case GLOBAL_PLACEHOLDER: /* already done: silently ignore */
case GLOBAL_SYMBOL:
return 0;
}
-static void cleanup_hashed_label(char *key, void *data)
-{
- /* The key is part of the permanent string storage */
- /* The data is part of the ldata chain */
- (void)key; (void)data;
-}
-
void cleanup_labels(void)
{
union label *lptr, *lhold;
initialized = FALSE;
- hash_free(ltab, cleanup_hashed_label);
-
+ hash_free(ltab);
lptr = lhold = ldata;
while (lptr) {
blk[LABEL_BLOCK - 1].admin.next = NULL;
}
-static char *perm_copy(char *string1, char *string2)
+static char *perm_copy(const char *string)
{
- char *p, *q;
- int len = strlen(string1) + strlen(string2) + 1;
+ char *p;
+ int len = strlen(string)+1;
if (perm_tail->size - perm_tail->usage < len) {
perm_tail->next =
perm_tail->size = PERMTS_SIZE;
perm_tail->usage = 0;
}
- p = q = perm_tail->data + perm_tail->usage;
- while ((*q = *string1++))
- q++;
- while ((*q++ = *string2++)) ;
- perm_tail->usage = q - perm_tail->data;
+ p = perm_tail->data + perm_tail->usage;
+ memcpy(p, string, len);
+ perm_tail->usage += len;
return p;
}