strdup.c (8a36da99deb0e19363ec04e4d3facd869c1028f5) strdup.c (744799ead25f22feac7621611b98391d1c80037e)
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2003 Networks Associates Technology, Inc.
5 * All rights reserved.
6 *
7 * This software was developed for the FreeBSD Project by Network
8 * Associates Laboratories, the Security Research Division of Network

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

35__FBSDID("$FreeBSD$");
36
37#include <sys/param.h>
38#include <sys/kernel.h>
39#include <sys/libkern.h>
40#include <sys/malloc.h>
41
42char *
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2003 Networks Associates Technology, Inc.
5 * All rights reserved.
6 *
7 * This software was developed for the FreeBSD Project by Network
8 * Associates Laboratories, the Security Research Division of Network

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

35__FBSDID("$FreeBSD$");
36
37#include <sys/param.h>
38#include <sys/kernel.h>
39#include <sys/libkern.h>
40#include <sys/malloc.h>
41
42char *
43strdup(const char *string, struct malloc_type *type)
43strdup_flags(const char *string, struct malloc_type *type, int flags)
44{
45 size_t len;
46 char *copy;
47
48 len = strlen(string) + 1;
44{
45 size_t len;
46 char *copy;
47
48 len = strlen(string) + 1;
49 copy = malloc(len, type, M_WAITOK);
49 copy = malloc(len, type, flags);
50 if (copy == NULL)
51 return (NULL);
50 bcopy(string, copy, len);
51 return (copy);
52}
52 bcopy(string, copy, len);
53 return (copy);
54}
55
56char *
57strdup(const char *string, struct malloc_type *type)
58{
59
60 return (strdup_flags(string, type, M_WAITOK));
61}