svn commit: r344384 - in head/sys: libkern sys
Matt Macy
mmacy at FreeBSD.org
Wed Feb 20 20:48:15 UTC 2019
Author: mmacy
Date: Wed Feb 20 20:48:10 2019
New Revision: 344384
URL: https://svnweb.freebsd.org/changeset/base/344384
Log:
Add non-sleepable strdup variant strdup_flags
debugfs expects to do non-sleepable allocations
Reviewed by: hps@
MFC after: 1 week
Sponsored by: iX Systems
Differential Revision: https://reviews.freebsd.org/D19259
Modified:
head/sys/libkern/strdup.c
head/sys/sys/libkern.h
Modified: head/sys/libkern/strdup.c
==============================================================================
--- head/sys/libkern/strdup.c Wed Feb 20 20:34:43 2019 (r344383)
+++ head/sys/libkern/strdup.c Wed Feb 20 20:48:10 2019 (r344384)
@@ -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: head/sys/sys/libkern.h
==============================================================================
--- head/sys/sys/libkern.h Wed Feb 20 20:34:43 2019 (r344383)
+++ head/sys/sys/libkern.h Wed Feb 20 20:48:10 2019 (r344384)
@@ -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 *);
More information about the svn-src-head
mailing list