mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-10 15:10:53 +00:00
libsysprof-capture: Use malloc() rather than g_new0() and friends
Another step away from GLib. This changes the OOM behaviour of the library — previously it would immediately `abort()` on OOM. However, it seems likely that given the small number of allocations libsysprof-capture does, it should be able to recover from an OOM situation more gracefully than larger libraries can — so the new implementation tries to do that. Signed-off-by: Philip Withnall <withnall@endlessm.com> Helps: #40
This commit is contained in:
@ -62,8 +62,20 @@
|
||||
# include <sys/sendfile.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static inline void *
|
||||
sysprof_malloc0 (size_t size)
|
||||
{
|
||||
void *ptr = malloc (size);
|
||||
if (ptr == NULL)
|
||||
return NULL;
|
||||
memset (ptr, 0, size);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
# define _sysprof_getpagesize() getpagesize()
|
||||
# define _sysprof_pread(a,b,c,d) pread(a,b,c,d)
|
||||
|
||||
Reference in New Issue
Block a user