Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F137928888
D13766.id37515.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1015 B
Referenced Files
None
Subscribers
None
D13766.id37515.diff
View Options
Index: sys/kern/kern_malloc.c
===================================================================
--- sys/kern/kern_malloc.c
+++ sys/kern/kern_malloc.c
@@ -534,6 +534,17 @@
return ((void *) va);
}
+void *
+mallocarray(size_t n, size_t size, struct malloc_type *type, int flags)
+{
+ size_t total = n * size;
+
+ if (n != 0 && (total / n) != size)
+ return (NULL);
+
+ return (malloc(total, type, flags));
+}
+
/*
* free:
*
Index: sys/sys/malloc.h
===================================================================
--- sys/sys/malloc.h
+++ sys/sys/malloc.h
@@ -177,6 +177,8 @@
void free(void *addr, struct malloc_type *type);
void *malloc(unsigned long size, struct malloc_type *type, int flags)
__malloc_like __result_use_check __alloc_size(1);
+void *mallocarray(size_t n, size_t size, struct malloc_type *type,
+ int flags) __malloc_like __result_use_check;
void malloc_init(void *);
int malloc_last_fail(void);
void malloc_type_allocated(struct malloc_type *type, unsigned long size);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 28, 8:48 AM (11 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26279174
Default Alt Text
D13766.id37515.diff (1015 B)
Attached To
Mode
D13766: Introduce mallocarray() in the kernel
Attached
Detach File
Event Timeline
Log In to Comment