Date: Sat, 25 May 2019 19:59:59 +0000 (UTC) From: Johannes Lundberg <johalun@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348278 - in stable/12/sys: libkern sys Message-ID: <201905251959.x4PJxx9I055394@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: johalun Date: Sat May 25 19:59:59 2019 New Revision: 348278 URL: https://svnweb.freebsd.org/changeset/base/348278 Log: MFC r344384: Add non-sleepable strdup variant strdup_flags debugfs expects to do non-sleepable allocations Reviewed by: hps@ Sponsored by: iX Systems Differential Revision: https://reviews.freebsd.org/D19259 Modified: stable/12/sys/libkern/strdup.c stable/12/sys/sys/libkern.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/libkern/strdup.c ============================================================================== --- stable/12/sys/libkern/strdup.c Sat May 25 18:36:38 2019 (r348277) +++ stable/12/sys/libkern/strdup.c Sat May 25 19:59:59 2019 (r348278) @@ -40,13 +40,22 @@ __FBSDID("$FreeBSD$"); #include <sys/malloc.h> char * -strdup(const char *string, struct malloc_type *type) +strdup_flags(const char *string, struct malloc_type *type, int flags) { size_t len; char *copy; len = strlen(string) + 1; - copy = malloc(len, type, M_WAITOK); + copy = malloc(len, type, flags); + if (copy == NULL) + return (NULL); bcopy(string, copy, len); return (copy); +} + +char * +strdup(const char *string, struct malloc_type *type) +{ + + return (strdup_flags(string, type, M_WAITOK)); } Modified: stable/12/sys/sys/libkern.h ============================================================================== --- stable/12/sys/sys/libkern.h Sat May 25 18:36:38 2019 (r348277) +++ stable/12/sys/sys/libkern.h Sat May 25 19:59:59 2019 (r348278) @@ -173,6 +173,7 @@ char *strchr(const char *, int); int strcmp(const char *, const char *); char *strcpy(char * __restrict, const char * __restrict); size_t strcspn(const char * __restrict, const char * __restrict) __pure; +char *strdup_flags(const char *__restrict, struct malloc_type *, int); char *strdup(const char *__restrict, struct malloc_type *); char *strncat(char *, const char *, size_t); char *strndup(const char *__restrict, size_t, struct malloc_type *);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905251959.x4PJxx9I055394>