src/libpfm4/lib/pfmlib_perf_event_pmu.c
/*
 * allocate space for overflow new unit masks
 *
 * Each event can hold up to PERF_MAX_UMASKS.
 * But gievn we can dynamically add events
 * which may have more unit masks, then we
 * put them into a separate overflow unit
 * masks,  table which can grow on demand.
 * In that case the first PERF_MAX_UMASKS
 * are in the event, the rest in the overflow
 * table at index pointed to by event->umask_ovfl_idx
 * All unit masks for an event are contiguous in the
 * overflow table.
 */
allocate space for overflow new unit masks
Each event can hold up to PERF_MAX_UMASKS.
But gievn we can dynamically add events
which may have more unit masks, then we
put them into a separate overflow unit
masks,  table which can grow on demand.
In that case the first PERF_MAX_UMASKS
are in the event, the rest in the overflow
table at index pointed to by event->umask_ovfl_idx
All unit masks for an event are contiguous in the
overflow table.
allocate space for overflow new unit masks Each event can hold up to PERF_MAX_UMASKS . But gievn we can dynamically add events which may have more unit masks then we put them into a separate overflow unit masks table which can grow on demand . In that case the first PERF_MAX_UMASKS are in the event the rest in the overflow table at index pointed to by event - > umask_ovfl_idx All unit masks for an event are contiguous in the overflow table .
static perf_umask_t *
perf_table_alloc_umask(void)
{
	perf_umask_t *new_um;
retry:
	if (perf_um_free < perf_um_end)
		return perf_um_free++;
	perf_um_count += PERF_ALLOC_UMASK_COUNT;
	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_end = perf_um_free + PERF_ALLOC_UMASK_COUNT;
	perf_um = new_um;
	goto retry;
}
static perf_umask_t * perf_table_alloc_umask ( void ) { perf_umask_t * new_um ; retry : if ( perf_um_free < perf_um_end ) return perf_um_free ++ ; perf_um_count += PERF_ALLOC_UMASK_COUNT ; 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_end = perf_um_free + PERF_ALLOC_UMASK_COUNT ; perf_um = new_um ; goto retry ; }
allocate space for overflow new unit masks
 Each event can hold up to PERF_MAX_UMASKS.
allocate space for overflow new unit masks Each event can hold up to PERF_MAX_UMASKS .