Add sc_allocarray() util
Add a function to allocate an array, which fails safely in the case where the multiplication would overflow.
This commit is contained in:
12
app/src/util/memory.h
Normal file
12
app/src/util/memory.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef SC_MEMORY_H
|
||||
#define SC_MEMORY_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* Like calloc(), but without initialization.
|
||||
* Like reallocarray(), but without reallocation.
|
||||
*/
|
||||
void *
|
||||
sc_allocarray(size_t nmemb, size_t size);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user