diff options
author | Mattias Andrée <maandree@kth.se> | 2021-03-08 00:21:02 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-03-08 00:21:02 +0100 |
commit | b058098fdcc5d4ed9b81fdb17f64820c0360ad48 (patch) | |
tree | e39e5f547b900922775d466507c29b352f046a53 /libgamma_value_of_subpixel_order.c | |
parent | misc (diff) | |
download | libgamma-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.c | 21 |
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 |