removed duplicatestring(), which was horribly broken and pretty useless

SVN revision: 14186
This commit is contained in:
tsauerbeck 2005-04-13 20:27:03 +00:00 committed by tsauerbeck
parent c1aa21b165
commit 155dc59a6f
4 changed files with 6 additions and 20 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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 */

View File

@ -28,19 +28,6 @@
#include <string.h>
#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;