[Pixman] [PATCH 6/7] _pixman_implementation_create(): Initialize implementation with memset()
Søren Sandmann
sandmann at cs.au.dk
Sat Sep 15 16:54:33 PDT 2012
From: Søren Sandmann Pedersen <ssp at redhat.com>
All the function pointers are NULL by default now, so we can just zero
the struct. Also write the function a little more compactly.
---
pixman/pixman-implementation.c | 35 +++++++++++------------------------
1 files changed, 11 insertions(+), 24 deletions(-)
diff --git a/pixman/pixman-implementation.c b/pixman/pixman-implementation.c
index 1da9d82..f371172 100644
--- a/pixman/pixman-implementation.c
+++ b/pixman/pixman-implementation.c
@@ -31,35 +31,22 @@ pixman_implementation_t *
_pixman_implementation_create (pixman_implementation_t *delegate,
const pixman_fast_path_t *fast_paths)
{
- pixman_implementation_t *imp = malloc (sizeof (pixman_implementation_t));
- pixman_implementation_t *d;
- int i;
-
- if (!imp)
- return NULL;
+ pixman_implementation_t *imp;
assert (fast_paths);
- /* Make sure the whole delegate chain has the right toplevel */
- imp->delegate = delegate;
- for (d = imp; d != NULL; d = d->delegate)
- d->toplevel = imp;
-
- /* Fill out function pointers with ones that just delegate
- */
- imp->blt = NULL;
- imp->fill = NULL;
- imp->src_iter_init = NULL;
- imp->dest_iter_init = NULL;
+ if ((imp = malloc (sizeof (pixman_implementation_t))))
+ {
+ pixman_implementation_t *d;
- imp->fast_paths = fast_paths;
+ memset (imp, 0, sizeof *imp);
- for (i = 0; i < PIXMAN_N_OPERATORS; ++i)
- {
- imp->combine_32[i] = NULL;
- imp->combine_64[i] = NULL;
- imp->combine_32_ca[i] = NULL;
- imp->combine_64_ca[i] = NULL;
+ imp->delegate = delegate;
+ imp->fast_paths = fast_paths;
+
+ /* Make sure the whole delegate chain has the right toplevel */
+ for (d = imp; d != NULL; d = d->delegate)
+ d->toplevel = imp;
}
return imp;
--
1.7.4
More information about the Pixman
mailing list