Use strdup(9) instead of reimplementing it.
This commit is contained in:
parent
50dc0db3f0
commit
196f2f42eb
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=254396
@ -153,16 +153,6 @@ static int linker_load_module(const char *kldname,
|
||||
struct mod_depend *verinfo, struct linker_file **lfpp);
|
||||
static modlist_t modlist_lookup2(const char *name, struct mod_depend *verinfo);
|
||||
|
||||
static char *
|
||||
linker_strdup(const char *str)
|
||||
{
|
||||
char *result;
|
||||
|
||||
if ((result = malloc((strlen(str) + 1), M_LINKER, M_WAITOK)) != NULL)
|
||||
strcpy(result, str);
|
||||
return (result);
|
||||
}
|
||||
|
||||
static void
|
||||
linker_init(void *arg)
|
||||
{
|
||||
@ -577,8 +567,8 @@ linker_make_file(const char *pathname, linker_class_t lc)
|
||||
lf->refs = 1;
|
||||
lf->userrefs = 0;
|
||||
lf->flags = 0;
|
||||
lf->filename = linker_strdup(filename);
|
||||
lf->pathname = linker_strdup(pathname);
|
||||
lf->filename = strdup(filename, M_LINKER);
|
||||
lf->pathname = strdup(pathname, M_LINKER);
|
||||
LINKER_GET_NEXT_FILE_ID(lf->id);
|
||||
lf->ndeps = 0;
|
||||
lf->deps = NULL;
|
||||
@ -1918,7 +1908,7 @@ linker_search_kld(const char *name)
|
||||
|
||||
/* qualified at all? */
|
||||
if (strchr(name, '/'))
|
||||
return (linker_strdup(name));
|
||||
return (strdup(name, M_LINKER));
|
||||
|
||||
/* traverse the linker path */
|
||||
len = strlen(name);
|
||||
@ -2011,7 +2001,7 @@ linker_load_module(const char *kldname, const char *modname,
|
||||
if (modlist_lookup2(modname, verinfo) != NULL)
|
||||
return (EEXIST);
|
||||
if (kldname != NULL)
|
||||
pathname = linker_strdup(kldname);
|
||||
pathname = strdup(kldname, M_LINKER);
|
||||
else if (rootvnode == NULL)
|
||||
pathname = NULL;
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user