/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2003 Networks Associates Technology, Inc.4* All rights reserved.5*6* This software was developed for the FreeBSD Project by Network7* Associates Laboratories, the Security Research Division of Network8* Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-80359* ("CBOSS"), as part of the DARPA CHATS research program.10*11* Redistribution and use in source and binary forms, with or without12* modification, are permitted provided that the following conditions13* are met:14* 1. Redistributions of source code must retain the above copyright15* notice, this list of conditions and the following disclaimer.16* 2. Redistributions in binary form must reproduce the above copyright17* notice, this list of conditions and the following disclaimer in the18* documentation and/or other materials provided with the distribution.19*20* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND21* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE22* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE23* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE24* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL25* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS26* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)27* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT28* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY29* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF30* SUCH DAMAGE.31*/3233#include <sys/param.h>34#include <sys/kernel.h>35#include <sys/libkern.h>36#include <sys/malloc.h>3738char *39strdup_flags(const char *string, struct malloc_type *type, int flags)40{41size_t len;42char *copy;4344len = strlen(string) + 1;45copy = malloc(len, type, flags);46if (copy == NULL)47return (NULL);48memcpy(copy, string, len);49return (copy);50}5152char *53strdup(const char *string, struct malloc_type *type)54{5556return (strdup_flags(string, type, M_WAITOK));57}585960