diff --git a/legacy/embryo/src/bin/embryo_cc_sc.h b/legacy/embryo/src/bin/embryo_cc_sc.h index 0fc8691c02..97bff61b8e 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc.h +++ b/legacy/embryo/src/bin/embryo_cc_sc.h @@ -586,7 +586,6 @@ int phopt_init(void); int phopt_cleanup(void); /* function prototypes in SCLIST.C */ -char *duplicatestring(const char *sourcestring); stringpair *insert_alias(char *name, char *alias); stringpair *find_alias(char *name); int lookup_alias(char *target, char *name); diff --git a/legacy/embryo/src/bin/embryo_cc_sc1.c b/legacy/embryo/src/bin/embryo_cc_sc1.c index 27b83f9fc7..23c0a4fe9f 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc1.c +++ b/legacy/embryo/src/bin/embryo_cc_sc1.c @@ -2727,7 +2727,7 @@ doarg(char *name, int ident, int offset, int tags[], int numtags, tokeninfo(&val, &name); if ((arg->defvalue.size.symname = - duplicatestring(name)) == NULL) + strdup(name)) == NULL) error(103); /* insufficient memory */ arg->defvalue.size.level = 0; if (size_tag_token == uSIZEOF) diff --git a/legacy/embryo/src/bin/embryo_cc_sc2.c b/legacy/embryo/src/bin/embryo_cc_sc2.c index d2facd115b..0f0ff23939 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc2.c +++ b/legacy/embryo/src/bin/embryo_cc_sc2.c @@ -122,7 +122,7 @@ plungequalifiedfile(char *name) pushstk((stkitem) fcurrent); /* FIXME: 64bit unsafe */ pushstk((stkitem) fline); - inpfname = duplicatestring(name); /* set name of include file */ + inpfname = strdup(name); /* set name of include file */ if (inpfname == NULL) error(103); /* insufficient memory */ inpf = fp; /* set input file pointer to include file */ @@ -934,7 +934,7 @@ command(void) if (strlen(pathname) > 0) { free(inpfname); - inpfname = duplicatestring(pathname); + inpfname = strdup(pathname); if (inpfname == NULL) error(103); /* insufficient memory */ } /* if */ diff --git a/legacy/embryo/src/bin/embryo_cc_sclist.c b/legacy/embryo/src/bin/embryo_cc_sclist.c index a8e0d67f48..f04840b515 100644 --- a/legacy/embryo/src/bin/embryo_cc_sclist.c +++ b/legacy/embryo/src/bin/embryo_cc_sclist.c @@ -28,19 +28,6 @@ #include #include "embryo_cc_sc.h" -/* a "private" implementation of strdup(), so that porting - * to other memory allocators becomes easier. - * By Søren Hannibal. - */ -char * -duplicatestring(const char *sourcestring) -{ - char *result = malloc(strlen(sourcestring) + 1); - - strcpy(result, sourcestring); - return result; -} - static stringpair * insert_stringpair(stringpair * root, char *first, char *second, int matchlength) { @@ -52,8 +39,8 @@ insert_stringpair(stringpair * root, char *first, char *second, int matchlength) /* create a new node, and check whether all is okay */ if ((cur = (stringpair *) malloc(sizeof(stringpair))) == NULL) return NULL; - cur->first = duplicatestring(first); - cur->second = duplicatestring(second); + cur->first = strdup(first); + cur->second = strdup(second); cur->matchlength = matchlength; if (cur->first == NULL || cur->second == NULL) { @@ -191,7 +178,7 @@ insert_path(char *path) assert(path != NULL); if ((cur = (stringlist *) malloc(sizeof(stringlist))) == NULL) error(103); /* insufficient memory (fatal error) */ - if ((cur->line = duplicatestring(path)) == NULL) + if ((cur->line = strdup(path)) == NULL) error(103); /* insufficient memory (fatal error) */ cur->next = includepaths.next; includepaths.next = cur;