196c4266cSRobert Watson /*- 296c4266cSRobert Watson * Copyright (c) 2003 Networks Associates Technology, Inc. 396c4266cSRobert Watson * All rights reserved. 496c4266cSRobert Watson * 5ae4f61f0SRobert Watson * This software was developed for the FreeBSD Project by Network 6ae4f61f0SRobert Watson * Associates Laboratories, the Security Research Division of Network 7ae4f61f0SRobert Watson * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 8ae4f61f0SRobert Watson * ("CBOSS"), as part of the DARPA CHATS research program. 996c4266cSRobert Watson * 1096c4266cSRobert Watson * Redistribution and use in source and binary forms, with or without 1196c4266cSRobert Watson * modification, are permitted provided that the following conditions 1296c4266cSRobert Watson * are met: 1396c4266cSRobert Watson * 1. Redistributions of source code must retain the above copyright 1496c4266cSRobert Watson * notice, this list of conditions and the following disclaimer. 1596c4266cSRobert Watson * 2. Redistributions in binary form must reproduce the above copyright 1696c4266cSRobert Watson * notice, this list of conditions and the following disclaimer in the 1796c4266cSRobert Watson * documentation and/or other materials provided with the distribution. 1896c4266cSRobert Watson * 1996c4266cSRobert Watson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2096c4266cSRobert Watson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2196c4266cSRobert Watson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2296c4266cSRobert Watson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2396c4266cSRobert Watson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2496c4266cSRobert Watson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2596c4266cSRobert Watson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2696c4266cSRobert Watson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2796c4266cSRobert Watson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2896c4266cSRobert Watson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2996c4266cSRobert Watson * SUCH DAMAGE. 3096c4266cSRobert Watson */ 3196c4266cSRobert Watson 32ab0de15bSDavid E. O'Brien #include <sys/cdefs.h> 33ab0de15bSDavid E. O'Brien __FBSDID("$FreeBSD$"); 34ab0de15bSDavid E. O'Brien 3596c4266cSRobert Watson #include <sys/param.h> 3696c4266cSRobert Watson #include <sys/kernel.h> 3796c4266cSRobert Watson #include <sys/libkern.h> 3896c4266cSRobert Watson #include <sys/malloc.h> 3996c4266cSRobert Watson 4096c4266cSRobert Watson char * 41354d43abSRobert Watson strdup(const char *string, struct malloc_type *type) 4296c4266cSRobert Watson { 4396c4266cSRobert Watson size_t len; 4496c4266cSRobert Watson char *copy; 4596c4266cSRobert Watson 4696c4266cSRobert Watson len = strlen(string) + 1; 47354d43abSRobert Watson copy = malloc(len, type, M_WAITOK); 4896c4266cSRobert Watson bcopy(string, copy, len); 4996c4266cSRobert Watson return (copy); 5096c4266cSRobert Watson } 51