diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2014-07-21 20:39:48 +0000 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2014-07-21 20:39:48 +0000 |
commit | 0f3f6485c8244000428c928fa0055e52e03c62f7 (patch) | |
tree | 6d94d5338e0b80b221c91b2dc1ea3247d008e9de /libgphoto2_port/gphoto2 | |
parent | 9cf5eebe233f882ba1889b28fc975087c5eb4934 (diff) | |
download | libgphoto2-0f3f6485c8244000428c928fa0055e52e03c62f7.tar.gz |
From: Axel Waggershauser <awagger@web.de>
here is a patch for (mostly) consistent usage of a generalized C_MEM
macro for checking the return values of memory allocating functions,
i.e. malloc, calloc, realloc and strdup. It is the C_MEM from
libusb1.c, moved to gphoto2-port-log.h.
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@15096 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'libgphoto2_port/gphoto2')
-rw-r--r-- | libgphoto2_port/gphoto2/gphoto2-port-log.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libgphoto2_port/gphoto2/gphoto2-port-log.h b/libgphoto2_port/gphoto2/gphoto2-port-log.h index f8a69a036..bcef73786 100644 --- a/libgphoto2_port/gphoto2/gphoto2-port-log.h +++ b/libgphoto2_port/gphoto2/gphoto2-port-log.h @@ -193,7 +193,13 @@ void gp_log_data (const char *domain, const char *data, unsigned int size); gpi_string_list_to_flags(const char *str[], const StringFlagItem *map); -#endif /* _GPHOTO2_INTERNAL_CODE */ +#define C_MEM(MEM) do {\ + if ((MEM) == NULL) {\ + GP_LOG_E ("Out of memory: '%s' failed.", #MEM);\ + return GP_ERROR_NO_MEMORY;\ + }\ +} while(0) +#endif /* _GPHOTO2_INTERNAL_CODE */ #endif /* __GPHOTO2_PORT_LOG_H__ */ |