mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 08:48:00 +02:00
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:
parent
b6be361d0e
commit
5135bcf414
1 changed files with 2 additions and 2 deletions
|
|
@ -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];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue