use realloc instead of free+calloc
This commit is contained in:
parent
a61ffc83dc
commit
5efc77fb1e
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: user.c,v 1.110 2006/06/02 21:44:37 jnemeth Exp $ */
|
/* $NetBSD: user.c,v 1.111 2006/06/27 12:39:23 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999 Alistair G. Crooks. All rights reserved.
|
* Copyright (c) 1999 Alistair G. Crooks. All rights reserved.
|
||||||
@ -33,7 +33,7 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
__COPYRIGHT("@(#) Copyright (c) 1999 \
|
__COPYRIGHT("@(#) Copyright (c) 1999 \
|
||||||
The NetBSD Foundation, Inc. All rights reserved.");
|
The NetBSD Foundation, Inc. All rights reserved.");
|
||||||
__RCSID("$NetBSD: user.c,v 1.110 2006/06/02 21:44:37 jnemeth Exp $");
|
__RCSID("$NetBSD: user.c,v 1.111 2006/06/27 12:39:23 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -218,15 +218,11 @@ check_numeric(const char *val, const char *name)
|
|||||||
return atoi(val);
|
return atoi(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if *cpp is non-null, free it, then assign `n' chars of `s' to it */
|
/* resize *cpp appropriately then assign `n' chars of `s' to it */
|
||||||
/* coverity[-free : arg-0] */
|
|
||||||
static void
|
static void
|
||||||
memsave(char **cpp, const char *s, size_t n)
|
memsave(char **cpp, const char *s, size_t n)
|
||||||
{
|
{
|
||||||
if (*cpp != NULL) {
|
RENEW(char, *cpp, n + 1, exit(1));
|
||||||
FREE(*cpp);
|
|
||||||
}
|
|
||||||
NEWARRAY(char, *cpp, n + 1, exit(1));
|
|
||||||
(void)memcpy(*cpp, s, n);
|
(void)memcpy(*cpp, s, n);
|
||||||
(*cpp)[n] = '\0';
|
(*cpp)[n] = '\0';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user