diff options
author | Jon Cruz <jonc@osg.samsung.com> | 2015-06-15 15:37:08 -0700 |
---|---|---|
committer | Bryce Harrington <bryce@osg.samsung.com> | 2015-06-15 17:11:45 -0700 |
commit | 35b2eaa989e4960501943c0753e2d5a3e687db92 (patch) | |
tree | d8f0f0b2304e22d18f1aae4496c8bb803188f438 /shared | |
parent | 4678bab13ce29b02363abfa40fd78cf94e107e8b (diff) | |
download | weston-35b2eaa989e4960501943c0753e2d5a3e687db92.tar.gz |
Moved helper macro to a discrete include file.
To help reduce code duplication and also 'kitchen-sink' includes
the ARRAY_LENGTH macro was moved to a stand-alone file and
referenced from the sources consuming it. Other macros will be
added in subsequent passes.
Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Diffstat (limited to 'shared')
-rw-r--r-- | shared/cairo-util.c | 3 | ||||
-rw-r--r-- | shared/helpers.h | 48 | ||||
-rw-r--r-- | shared/image-loader.c | 3 |
3 files changed, 50 insertions, 4 deletions
diff --git a/shared/cairo-util.c b/shared/cairo-util.c index f6d02a89..21fcbea5 100644 --- a/shared/cairo-util.c +++ b/shared/cairo-util.c @@ -35,11 +35,10 @@ #include <cairo.h> #include "cairo-util.h" +#include "shared/helpers.h" #include "image-loader.h" #include "config-parser.h" -#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) - void surface_flush_device(cairo_surface_t *surface) { diff --git a/shared/helpers.h b/shared/helpers.h new file mode 100644 index 00000000..7502ff32 --- /dev/null +++ b/shared/helpers.h @@ -0,0 +1,48 @@ +/* + * Copyright © 2015 Samsung Electronics Co., Ltd + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef WESTON_HELPERS_H +#define WESTON_HELPERS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file + * Simple misc helper macros. + */ + +/** + * Compile-time computation of number of items in a hardcoded array. + * + * @param a the array being measured. + * @return the number of items hardcoded into the array. + */ +#ifndef ARRAY_LENGTH +#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* WESTON_HELPERS_H */ diff --git a/shared/image-loader.c b/shared/image-loader.c index b01266c8..ec75bd4f 100644 --- a/shared/image-loader.c +++ b/shared/image-loader.c @@ -34,10 +34,9 @@ #include <png.h> #include <pixman.h> +#include "shared/helpers.h" #include "image-loader.h" -#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) - #ifdef HAVE_WEBP #include <webp/decode.h> #endif |