Pass a malloc type into the libkern strdup() implementation explicitly,

so that callers can specify what malloc pool the resulting memory
should come from.

Requested by:	phk
This commit is contained in:
Robert Watson 2003-02-25 22:11:39 +00:00
parent 9fed9b054d
commit 354d43abf3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=111506
2 changed files with 4 additions and 3 deletions

View File

@ -42,13 +42,13 @@
MALLOC_DEFINE(M_STRING, "string", "string buffers");
char *
strdup(const char *string)
strdup(const char *string, struct malloc_type *type)
{
size_t len;
char *copy;
len = strlen(string) + 1;
copy = malloc(len, M_STRING, M_WAITOK);
copy = malloc(len, type, M_WAITOK);
bcopy(string, copy, len);
return (copy);
}

View File

@ -68,6 +68,7 @@ static __inline long labs(long a) { return (a < 0 ? -a : a); }
static __inline quad_t qabs(quad_t a) { return (a < 0 ? -a : a); }
/* Prototypes for non-quad routines. */
struct malloc_type;
uint32_t arc4random(void);
void arc4rand(void *ptr, u_int len, int reseed);
int bcmp(const void *, const void *, size_t);
@ -92,7 +93,7 @@ void srandom(u_long);
char *strcat(char * __restrict, const char * __restrict);
int strcmp(const char *, const char *);
char *strcpy(char * __restrict, const char * __restrict);
char *strdup(const char *__restrict);
char *strdup(const char *__restrict, struct malloc_type *);
size_t strlcat(char *, const char *, size_t);
size_t strlcpy(char *, const char *, size_t);
size_t strlen(const char *);