mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
Merge branch 'musl' into 'master'
sysprof 3.38 on Linux with musl libc See merge request GNOME/sysprof!37
This commit is contained in:
@ -69,6 +69,7 @@ config_h.set('LOCALEDIR', 'PACKAGE_LOCALE_DIR')
|
||||
config_h.set('HAVE_EXECINFO_H', cc.has_header('execinfo.h'))
|
||||
|
||||
config_h.set('HAVE_STRLCPY', cc.has_function('strlcpy'))
|
||||
config_h.set('HAVE_REALLOCARRAY', cc.has_function('reallocarray'))
|
||||
|
||||
if get_option('libunwind')
|
||||
libunwind_dep = dependency('libunwind-generic', required: false)
|
||||
|
||||
@ -269,6 +269,7 @@ sysprof_capture_condition_copy (const SysprofCaptureCondition *self)
|
||||
}
|
||||
|
||||
sysprof_assert_not_reached ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@ -293,7 +293,9 @@ sysprof_capture_cursor_add_condition (SysprofCaptureCursor *self,
|
||||
*
|
||||
* FIXME: There’s currently no error reporting from this function, so ENOMEM
|
||||
* results in an abort. */
|
||||
self->conditions = reallocarray (self->conditions, ++self->n_conditions, sizeof (*self->conditions));
|
||||
self->conditions = _sysprof_reallocarray (self->conditions,
|
||||
++self->n_conditions,
|
||||
sizeof (*self->conditions));
|
||||
assert (self->conditions != NULL);
|
||||
|
||||
self->conditions[self->n_conditions - 1] = sysprof_steal_pointer (&condition);
|
||||
|
||||
@ -1270,7 +1270,7 @@ array_append (const char ***files,
|
||||
const char **new_files;
|
||||
|
||||
*n_files_allocated = (*n_files_allocated > 0) ? 2 * *n_files_allocated : 4;
|
||||
new_files = reallocarray (*files, *n_files_allocated, sizeof (**files));
|
||||
new_files = _sysprof_reallocarray (*files, *n_files_allocated, sizeof (**files));
|
||||
if (new_files == NULL)
|
||||
return false;
|
||||
*files = new_files;
|
||||
|
||||
@ -60,10 +60,19 @@
|
||||
# include <sys/sendfile.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef TEMP_FAILURE_RETRY
|
||||
#define TEMP_FAILURE_RETRY(expression) \
|
||||
({ long int __result; \
|
||||
do { __result = (long int) (expression); } \
|
||||
while (__result == -1L && errno == EINTR); \
|
||||
__result; })
|
||||
#endif
|
||||
|
||||
static inline void *
|
||||
sysprof_malloc0 (size_t size)
|
||||
{
|
||||
@ -108,3 +117,11 @@ size_t _sysprof_strlcpy (char *dest,
|
||||
const char *src,
|
||||
size_t dest_size);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_REALLOCARRAY
|
||||
# define _sysprof_reallocarray(p,m,n) reallocarray(p,m,n)
|
||||
#else
|
||||
void *_sysprof_reallocarray (void *ptr,
|
||||
size_t m,
|
||||
size_t n);
|
||||
#endif
|
||||
|
||||
@ -58,6 +58,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
@ -253,3 +254,15 @@ size_t
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
void *
|
||||
(_sysprof_reallocarray) (void *ptr,
|
||||
size_t m,
|
||||
size_t n)
|
||||
{
|
||||
if (n && m > (size_t)(-1) / n) {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
return realloc(ptr, m * n);
|
||||
}
|
||||
|
||||
@ -64,6 +64,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "sysprof-capture.h"
|
||||
#include "sysprof-capture-util-private.h"
|
||||
#include "sysprof-macros-internal.h"
|
||||
|
||||
typedef struct
|
||||
@ -133,7 +134,7 @@ translate_table_add (TranslateTable *tables,
|
||||
if (table_ptr->n_items == table_ptr->n_items_allocated)
|
||||
{
|
||||
table_ptr->n_items_allocated = (table_ptr->n_items_allocated > 0) ? table_ptr->n_items_allocated * 2 : 4;
|
||||
table_ptr->items = reallocarray (table_ptr->items, table_ptr->n_items_allocated, sizeof (*table_ptr->items));
|
||||
table_ptr->items = _sysprof_reallocarray (table_ptr->items, table_ptr->n_items_allocated, sizeof (*table_ptr->items));
|
||||
assert (table_ptr->items != NULL);
|
||||
}
|
||||
|
||||
@ -481,8 +482,8 @@ sysprof_capture_writer_cat (SysprofCaptureWriter *self,
|
||||
if (n_elements == n_elements_allocated)
|
||||
{
|
||||
n_elements_allocated = (n_elements_allocated > 0) ? n_elements_allocated * 2 : 4;
|
||||
ids = reallocarray (ids, n_elements_allocated, sizeof (*ids));
|
||||
values = reallocarray (values, n_elements_allocated, sizeof (*values));
|
||||
ids = _sysprof_reallocarray (ids, n_elements_allocated, sizeof (*ids));
|
||||
values = _sysprof_reallocarray (values, n_elements_allocated, sizeof (*values));
|
||||
if (ids == NULL || values == NULL)
|
||||
goto panic;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user