57 lines
1.4 KiB
Diff
57 lines
1.4 KiB
Diff
Index: papi-5.7.0/src/libpfm4/lib/pfmlib_perf_event_pmu.c
|
|
===================================================================
|
|
--- papi-5.7.0.orig/src/libpfm4/lib/pfmlib_perf_event_pmu.c
|
|
+++ papi-5.7.0/src/libpfm4/lib/pfmlib_perf_event_pmu.c
|
|
@@ -23,6 +23,7 @@
|
|
*/
|
|
#include <sys/types.h>
|
|
#include <string.h>
|
|
+#include <stddef.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
@@ -254,6 +255,7 @@ static perf_event_t *
|
|
perf_table_alloc_event(void)
|
|
{
|
|
perf_event_t *new_pe;
|
|
+ ptrdiff_t offset;
|
|
|
|
retry:
|
|
if (perf_pe_free < perf_pe_end)
|
|
@@ -261,11 +263,12 @@ retry:
|
|
|
|
perf_pe_count += PERF_ALLOC_EVENT_COUNT;
|
|
|
|
+ offset = perf_pe_free - perf_pe;
|
|
new_pe = realloc(perf_pe, perf_pe_count * sizeof(perf_event_t));
|
|
if (!new_pe)
|
|
return NULL;
|
|
|
|
- perf_pe_free = new_pe + (perf_pe_free - perf_pe);
|
|
+ perf_pe_free = new_pe + offset;
|
|
perf_pe_end = perf_pe_free + PERF_ALLOC_EVENT_COUNT;
|
|
perf_pe = new_pe;
|
|
|
|
@@ -290,6 +293,7 @@ static perf_umask_t *
|
|
perf_table_alloc_umask(void)
|
|
{
|
|
perf_umask_t *new_um;
|
|
+ ptrdiff_t offset;
|
|
|
|
retry:
|
|
if (perf_um_free < perf_um_end)
|
|
@@ -297,11 +301,12 @@ retry:
|
|
|
|
perf_um_count += PERF_ALLOC_UMASK_COUNT;
|
|
|
|
+ offset = perf_um_free - perf_um;
|
|
new_um = realloc(perf_um, perf_um_count * sizeof(*new_um));
|
|
if (!new_um)
|
|
return NULL;
|
|
|
|
- perf_um_free = new_um + (perf_um_free - perf_um);
|
|
+ perf_um_free = new_um + offset;
|
|
perf_um_end = perf_um_free + PERF_ALLOC_UMASK_COUNT;
|
|
perf_um = new_um;
|
|
|