aboutsummaryrefslogtreecommitdiffstats
path: root/libgamma_value_of_subpixel_order.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-03-08 00:21:02 +0100
committerMattias Andrée <maandree@kth.se>2021-03-08 00:21:02 +0100
commitb058098fdcc5d4ed9b81fdb17f64820c0360ad48 (patch)
treee39e5f547b900922775d466507c29b352f046a53 /libgamma_value_of_subpixel_order.c
parentmisc (diff)
downloadlibgamma-b058098fdcc5d4ed9b81fdb17f64820c0360ad48.tar.gz
libgamma-b058098fdcc5d4ed9b81fdb17f64820c0360ad48.tar.bz2
libgamma-b058098fdcc5d4ed9b81fdb17f64820c0360ad48.tar.xz
m + style fix + check memory allocation overflows
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--libgamma_value_of_subpixel_order.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/libgamma_value_of_subpixel_order.c b/libgamma_value_of_subpixel_order.c
index 33c2a6f..ed81435 100644
--- a/libgamma_value_of_subpixel_order.c
+++ b/libgamma_value_of_subpixel_order.c
@@ -7,22 +7,27 @@
*
* @param order The name of the subpixel order, for example
* "Horizontal RGB" or "LIBGAMMA_SUBPIXEL_ORDER_HORIZONTAL_RGB"
- * @return The subpixel order; for example `LIBGAMMA_SUBPIXEL_ORDER_HORIZONTAL_RGB`
- * for "Horizontal RGB" and "LIBGAMMA_SUBPIXEL_ORDER_HORIZONTAL_RGB";
- * `LIBGAMMA_SUBPIXEL_ORDER_NOT_RECOGNISED` of not defined
+ * @param out Output parameter for the subpixel order, only set on success;
+ * for example `LIBGAMMA_SUBPIXEL_ORDER_HORIZONTAL_RGB` for
+ * "Horizontal RGB" and "LIBGAMMA_SUBPIXEL_ORDER_HORIZONTAL_RGB";
+ * @return Zero on success, `LIBGAMMA_SUBPIXEL_ORDER_NOT_RECOGNISED` of not defined
*/
int
-libgamma_value_of_subpixel_order(const char *order)
+libgamma_value_of_subpixel_order(const char *order, enum libgamma_subpixel_order *out)
{
#define X(CONST, NAME, ...)\
- if (!strcmp(order, NAME))\
- return CONST;
+ if (!strcmp(order, NAME)) {\
+ *out = CONST;\
+ return 0;\
+ }
LIST_SUBPIXEL_ORDERS(X)
#undef X
#define X(CONST, ...)\
- if (!strcmp(order, #CONST))\
- return CONST;
+ if (!strcmp(order, #CONST)) {\
+ *out = CONST;\
+ return 0;\
+ }
LIST_SUBPIXEL_ORDERS(X)
#undef X