Skip to content
Snippets Groups Projects
Commit 34fbc579 authored by Simon McVittie's avatar Simon McVittie
Browse files

check-va-api: Use common xcalloc() for allocations that "can't fail"


If we run out of memory (unlikely in practice because the Linux kernel
overcommits), then we're just going to crash out anyway, so use a
GLib-like model to simplify error handling.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent 2cd3c892
Branches
Tags
1 merge request!801check-va-api: Use supported surface format + opportunistic cleanup
...@@ -505,14 +505,7 @@ main (int argc, ...@@ -505,14 +505,7 @@ main (int argc,
"vaMaxNumProfiles failed: unexpected number of maximum profiles (%i)\n", max_profiles); "vaMaxNumProfiles failed: unexpected number of maximum profiles (%i)\n", max_profiles);
goto out; goto out;
} }
profiles = calloc (max_profiles, sizeof (VAProfile)); profiles = xcalloc (max_profiles, sizeof (VAProfile));
if (profiles == NULL)
{
fprintf (stderr, "Out of memory\n");
goto out;
}
do_vaapi_or_exit (vaQueryConfigProfiles (va_display, profiles, &num_profiles)); do_vaapi_or_exit (vaQueryConfigProfiles (va_display, profiles, &num_profiles));
if (num_profiles > max_profiles) if (num_profiles > max_profiles)
{ {
...@@ -522,14 +515,7 @@ main (int argc, ...@@ -522,14 +515,7 @@ main (int argc,
goto out; goto out;
} }
surfaces = calloc (surfaces_count, sizeof (VASurfaceID)); surfaces = xcalloc (surfaces_count, sizeof (VASurfaceID));
if (surfaces == NULL)
{
fprintf (stderr, "Out of memory\n");
goto out;
}
/* Test the creation of two surfaces and an image */ /* Test the creation of two surfaces and an image */
do_vaapi_or_exit (vaCreateSurfaces (va_display, VA_RT_FORMAT_YUV420, width, height, do_vaapi_or_exit (vaCreateSurfaces (va_display, VA_RT_FORMAT_YUV420, width, height,
surfaces, surfaces_count, &attr, 1)); surfaces, surfaces_count, &attr, 1));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment