strdup.c (96c4266cb3ec0dfe1c78d4661551284f4ffdfa2a) strdup.c (354d43abf30325d0059644e2b7bfe2d194041c99)
1/*-
2 * Copyright (c) 2003 Networks Associates Technology, Inc.
3 * All rights reserved.
4 *
5 * This software was developed for the FreeBSD Project by NAI Labs,
6 * the Security Research Division of Network Associates, Inc. under
7 * DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA
8 * CHATS research program.

--- 28 unchanged lines hidden (view full) ---

37#include <sys/param.h>
38#include <sys/kernel.h>
39#include <sys/libkern.h>
40#include <sys/malloc.h>
41
42MALLOC_DEFINE(M_STRING, "string", "string buffers");
43
44char *
1/*-
2 * Copyright (c) 2003 Networks Associates Technology, Inc.
3 * All rights reserved.
4 *
5 * This software was developed for the FreeBSD Project by NAI Labs,
6 * the Security Research Division of Network Associates, Inc. under
7 * DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA
8 * CHATS research program.

--- 28 unchanged lines hidden (view full) ---

37#include <sys/param.h>
38#include <sys/kernel.h>
39#include <sys/libkern.h>
40#include <sys/malloc.h>
41
42MALLOC_DEFINE(M_STRING, "string", "string buffers");
43
44char *
45strdup(const char *string)
45strdup(const char *string, struct malloc_type *type)
46{
47 size_t len;
48 char *copy;
49
50 len = strlen(string) + 1;
46{
47 size_t len;
48 char *copy;
49
50 len = strlen(string) + 1;
51 copy = malloc(len, M_STRING, M_WAITOK);
51 copy = malloc(len, type, M_WAITOK);
52 bcopy(string, copy, len);
53 return (copy);
54}
52 bcopy(string, copy, len);
53 return (copy);
54}