cairo-boilerplate - use xmalloc and friends

Prefer to abort gracefully if we run out of memory (or simply to protect
them from memfault).
This commit is contained in:
Chris Wilson 2007-04-20 19:08:07 +01:00
parent b6be361d0e
commit 5135bcf414

View file

@ -379,7 +379,7 @@ cairo_boilerplate_get_targets (int *pnum_targets, cairo_bool_t *plimited_targets
if (0 == strncmp (targets[i].name, tname, end - tname) &&
!isalnum (targets[i].name[end - tname])) {
/* realloc isn't exactly the best thing here, but meh. */
targets_to_test = realloc (targets_to_test, sizeof(cairo_boilerplate_target_t *) * (num_targets+1));
targets_to_test = xrealloc (targets_to_test, sizeof(cairo_boilerplate_target_t *) * (num_targets+1));
targets_to_test[num_targets++] = &targets[i];
found = 1;
}
@ -396,7 +396,7 @@ cairo_boilerplate_get_targets (int *pnum_targets, cairo_bool_t *plimited_targets
}
} else {
num_targets = sizeof (targets) / sizeof (targets[0]);
targets_to_test = malloc (sizeof(cairo_boilerplate_target_t*) * num_targets);
targets_to_test = xmalloc (sizeof(cairo_boilerplate_target_t*) * num_targets);
for (i = 0; i < num_targets; i++) {
targets_to_test[i] = &targets[i];
}