Skip to content

Commit

Permalink
Rip out Salloc() and replace it with strdup().
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgiven committed Dec 8, 2024
1 parent 424dabd commit a5c1726
Show file tree
Hide file tree
Showing 40 changed files with 659 additions and 623 deletions.
7 changes: 4 additions & 3 deletions lang/cem/cemcom.ansi/LLlex.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <assert.h>
#include <alloc.h>
#include <stdlib.h>
#include <string.h>
#include "parameters.h"
#include "input.h"
#include "arith.h"
Expand Down Expand Up @@ -363,7 +364,7 @@ int GetToken(struct token* ptok)
if ((flags & FLG_DOTSEEN)
|| (flags & FLG_ESEEN && !(ch == '0' && (*np == 'x' || *np == 'X'))))
{
ptok->tk_fval = Salloc("0.0", (unsigned)4);
ptok->tk_fval = strdup("0.0");
ptok->tk_fund = DOUBLE;
return ptok->tk_symb = FLOATING;
}
Expand Down Expand Up @@ -584,11 +585,11 @@ static void strflt2tok(char fltbuf[], struct token* ptok)
if (malformed)
{
lexerror("malformed floating constant");
ptok->tk_fval = Salloc("0.0", (unsigned)4);
ptok->tk_fval = strdup("0.0");
}
else
{
ptok->tk_fval = Salloc(fltbuf, (unsigned)(cp - fltbuf + 1));
ptok->tk_fval = strdup(fltbuf);
}
}

Expand Down
5 changes: 3 additions & 2 deletions lang/cem/cemcom.ansi/LLmessage.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/* $Id$ */
/* PARSER ERROR ADMINISTRATION */

#include <string.h>
#include <alloc.h>
#include "idf.h"
#include "arith.h"
Expand Down Expand Up @@ -57,15 +58,15 @@ static void insert_token(int tk)
dot.tk_idf = str2idf("int", 0);
break;
case STRING:
dot.tk_bts = Salloc("", 1);
dot.tk_bts = strdup("");
dot.tk_len = 1;
break;
case INTEGER:
dot.tk_fund = INT;
dot.tk_ival = 1;
break;
case FLOATING:
dot.tk_fval = Salloc("0.0", 4);
dot.tk_fval = strdup("0.0");
break;
}
}
2 changes: 1 addition & 1 deletion lang/cem/cemcom.ansi/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void compile(int argc, char *argv[])
FileName = source = argv[0];
else {
source = 0;
FileName = Salloc("standard input", (unsigned) 16);
FileName = strdup("standard input");
}

if (!InsertFile(source, (char **) 0, &result)) /* read the source file */
Expand Down
4 changes: 2 additions & 2 deletions lang/cem/cemcom/LLlex.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,10 @@ GetToken(ptok)
buf[0] = '-'; /* good heavens... */
if (np == &buf[NUMSIZE+1]) {
lexerror("floating constant too long");
ptok->tk_fval = Salloc("-0.0",(unsigned) 5) + 1;
ptok->tk_fval = strdup("-0.0") + 1;
}
else
ptok->tk_fval = Salloc(buf,(unsigned) (np - buf)) + 1;
ptok->tk_fval = strdup(buf) + 1;
return ptok->tk_symb = FLOATING;
#endif /* NOFLOAT */
}
Expand Down
4 changes: 2 additions & 2 deletions lang/cem/cemcom/LLmessage.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ insert_token(tk)
dot.tk_idf = str2idf("int");
break;
case STRING:
dot.tk_bts = Salloc("", 1);
dot.tk_bts = strdup("");
dot.tk_len = 1;
break;
case INTEGER:
Expand All @@ -60,7 +60,7 @@ insert_token(tk)
break;
#ifndef NOFLOAT
case FLOATING:
dot.tk_fval = Salloc("0.0", 4);
dot.tk_fval = strdup("0.0");
break;
#endif /* NOFLOAT */
}
Expand Down
2 changes: 1 addition & 1 deletion lang/cem/cemcom/arith.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ int2float(expp, tp)
exp = *expp;
exp->ex_type = tp;
exp->ex_class = Float;
exp->FL_VALUE = Salloc(buf, (unsigned)strlen(buf)+2) + 1;
exp->FL_VALUE = strdup(buf) + 1;
exp->FL_DATLAB = 0;
}
else *expp = arith2arith(tp, INT2FLOAT, *expp);
Expand Down
2 changes: 1 addition & 1 deletion lang/cem/cemcom/idf.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ idf_hashed(tg, size, hc)
notch = new_idf();
notch->next = *hook;
*hook = notch; /* hooked in */
notch->id_text = Salloc(tg, (unsigned) size);
notch->id_text = strdup(tg);
#ifndef NOPP
notch->id_resmac = 0;
#endif /* NOPP */
Expand Down
2 changes: 1 addition & 1 deletion lang/cem/cemcom/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ getwdir(fn)
return "";
if (p) {
*p = '\0';
fn = Salloc(fn, p - &fn[0] + 1);
fn = strdup(fn);
*p = '/';
return fn;
}
Expand Down
2 changes: 1 addition & 1 deletion lang/cem/cpp.ansi/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ char* getwdir(char* fn)
if (p)
{
*p = '\0';
fn = Salloc(fn, (unsigned)(p - &fn[0] + 1));
fn = strdup(fn);
*p = '/';
return fn;
}
Expand Down
4 changes: 2 additions & 2 deletions lang/cem/cpp.ansi/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ void do_option(char *text)
++cp;
if (!*cp) { /* -Dname */
maclen = 1;
mactext = Salloc("1", 2);
mactext = strdup("1");
} else
if (*cp == '=') { /* -Dname=text */
*cp++ = '\0'; /* end of name */
maclen = strlen(cp);
mactext = Salloc(cp, maclen + 1);
mactext = strdup(cp);
}
else { /* -Dname?? */
error("malformed option -D%s", text);
Expand Down
Loading

0 comments on commit a5c1726

Please sign in to comment.