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:
parent
9fed9b054d
commit
354d43abf3
@ -42,13 +42,13 @@
|
|||||||
MALLOC_DEFINE(M_STRING, "string", "string buffers");
|
MALLOC_DEFINE(M_STRING, "string", "string buffers");
|
||||||
|
|
||||||
char *
|
char *
|
||||||
strdup(const char *string)
|
strdup(const char *string, struct malloc_type *type)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
char *copy;
|
char *copy;
|
||||||
|
|
||||||
len = strlen(string) + 1;
|
len = strlen(string) + 1;
|
||||||
copy = malloc(len, M_STRING, M_WAITOK);
|
copy = malloc(len, type, M_WAITOK);
|
||||||
bcopy(string, copy, len);
|
bcopy(string, copy, len);
|
||||||
return (copy);
|
return (copy);
|
||||||
}
|
}
|
||||||
|
@ -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); }
|
static __inline quad_t qabs(quad_t a) { return (a < 0 ? -a : a); }
|
||||||
|
|
||||||
/* Prototypes for non-quad routines. */
|
/* Prototypes for non-quad routines. */
|
||||||
|
struct malloc_type;
|
||||||
uint32_t arc4random(void);
|
uint32_t arc4random(void);
|
||||||
void arc4rand(void *ptr, u_int len, int reseed);
|
void arc4rand(void *ptr, u_int len, int reseed);
|
||||||
int bcmp(const void *, const void *, size_t);
|
int bcmp(const void *, const void *, size_t);
|
||||||
@ -92,7 +93,7 @@ void srandom(u_long);
|
|||||||
char *strcat(char * __restrict, const char * __restrict);
|
char *strcat(char * __restrict, const char * __restrict);
|
||||||
int strcmp(const char *, const char *);
|
int strcmp(const char *, const char *);
|
||||||
char *strcpy(char * __restrict, const char * __restrict);
|
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 strlcat(char *, const char *, size_t);
|
||||||
size_t strlcpy(char *, const char *, size_t);
|
size_t strlcpy(char *, const char *, size_t);
|
||||||
size_t strlen(const char *);
|
size_t strlen(const char *);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user