ref: 34cf2725d2f8af3db84b77711af7b2559aa131fd
parent: ecdf3f921e2a2ec768807bb09e0e7da995612565
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue May 12 18:45:05 EDT 2020
cc: get rid of hunk pointer fiddling and just use alloc()
--- a/sys/src/cmd/cc/macbody
+++ b/sys/src/cmd/cc/macbody
@@ -138,15 +138,8 @@
*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 @@
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 @@
* 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;