summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2003-02-25 22:11:39 +0000
committerrwatson <rwatson@FreeBSD.org>2003-02-25 22:11:39 +0000
commita3f8d3d8190991dc750a8ef3f91002bc9f877b26 (patch)
tree70fd88f9ba7b8e2d04834e82ef3c97ee8383e902
parented93a50e90cdfa5ea6810c133e52dcbe46d642a3 (diff)
downloadFreeBSD-src-a3f8d3d8190991dc750a8ef3f91002bc9f877b26.zip
FreeBSD-src-a3f8d3d8190991dc750a8ef3f91002bc9f877b26.tar.gz
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
-rw-r--r--sys/libkern/strdup.c4
-rw-r--r--sys/sys/libkern.h3
2 files changed, 4 insertions, 3 deletions
diff --git a/sys/libkern/strdup.c b/sys/libkern/strdup.c
index 74953ff..82cece0 100644
--- a/sys/libkern/strdup.c
+++ b/sys/libkern/strdup.c
@@ -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);
}
diff --git a/sys/sys/libkern.h b/sys/sys/libkern.h
index e3efad7..ba794e3 100644
--- a/sys/sys/libkern.h
+++ b/sys/sys/libkern.h
@@ -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 *);
OpenPOWER on IntegriCloud