summaryrefslogtreecommitdiff
path: root/src/sym.c
diff options
context:
space:
mode:
authorMichael McConville <mmcconville@mykolab.com>2015-12-02 11:32:42 -0500
committerWill Estes <westes575@gmail.com>2015-12-02 14:39:09 -0500
commit399e94f904b913a4093295426820ab89fc3cd24f (patch)
treeac04185a0167975ba0b6ba6265a5a11e1e536761 /src/sym.c
parent9ba6e5283efd2fe454d3bc92eca960b3ebd91294 (diff)
Made string copying more standard.
copy_string() was a clone of the stdlib's strdup(). For safety, simplicity, and speed, we should use that instead. We introduce xstrdup() which wraps strdup() in a failure upon memory allocation errors.
Diffstat (limited to 'src/sym.c')
-rw-r--r--src/sym.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/sym.c b/src/sym.c
index 568a24b..e6f556c 100644
--- a/src/sym.c
+++ b/src/sym.c
@@ -181,7 +181,7 @@ static int hashfunct (const char *str, int hash_size)
void ndinstal (const char *name, unsigned char definition[])
{
- if (addsym (copy_string (name),
+ if (addsym (xstrdup(name),
(char *) copy_unsigned_string (definition), 0,
ndtbl, NAME_TABLE_HASH_SIZE))
synerr (_("name defined twice"));
@@ -227,7 +227,7 @@ void scinstal (const char *str, int xcluflg)
if (++lastsc >= current_max_scs)
scextend ();
- scname[lastsc] = copy_string (str);
+ scname[lastsc] = xstrdup(str);
if (addsym (scname[lastsc], (char *) 0, lastsc,
sctbl, START_COND_HASH_SIZE))