summaryrefslogtreecommitdiff
path: root/sys/src/cmd/cc
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2020-05-12 22:45:05 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2020-05-12 22:45:05 +0200
commit34cf2725d2f8af3db84b77711af7b2559aa131fd (patch)
tree6e239a5c69b266d147d86e227888f5f605da95ea /sys/src/cmd/cc
parentecdf3f921e2a2ec768807bb09e0e7da995612565 (diff)
cc: get rid of hunk pointer fiddling and just use alloc()
Diffstat (limited to 'sys/src/cmd/cc')
-rw-r--r--sys/src/cmd/cc/macbody33
1 files changed, 6 insertions, 27 deletions
diff --git a/sys/src/cmd/cc/macbody b/sys/src/cmd/cc/macbody
index ec15369f7..efe119a4a 100644
--- a/sys/src/cmd/cc/macbody
+++ b/sys/src/cmd/cc/macbody
@@ -138,15 +138,8 @@ dodefine(char *cp)
*p++ = 0;
s = lookup();
l = strlen(p) + 2; /* +1 null, +1 nargs */
- while(l & 3)
- l++;
- while(nhunk < l)
- gethunk();
- *hunk = 0;
- strcpy(hunk+1, p);
- s->macro = hunk;
- hunk += l;
- nhunk -= l;
+ s->macro = alloc(l);
+ memcpy(s->macro, p-1, l);
} else {
s = lookup();
s->macro = "\0001"; /* \000 is nargs */
@@ -640,14 +633,8 @@ maclin(void)
nn:
c = strlen(symb) + 1;
- while(c & 3)
- c++;
- while(nhunk < c)
- gethunk();
- cp = hunk;
- memcpy(hunk, symb, c);
- nhunk -= c;
- hunk += c;
+ cp = alloc(c);
+ memcpy(cp, symb, c);
linehist(cp, n);
return;
@@ -774,17 +761,9 @@ praglib:
* put pragma-line in as a funny history
*/
c = strlen(symb) + 1;
- while(c & 3)
- c++;
- while(nhunk < c)
- gethunk();
- hp = hunk;
- memcpy(hunk, symb, c);
- nhunk -= c;
- hunk += c;
-
h = alloc(sizeof(Hist));
- h->name = hp;
+ h->name = alloc(c);
+ memcpy(h->name, symb, c);
h->line = lineno;
h->offset = -1;
h->link = H;