summaryrefslogtreecommitdiff
path: root/libgphoto2_port/usbdiskdirect/linux.c
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2014-07-21 20:39:48 +0000
committerMarcus Meissner <marcus@jet.franken.de>2014-07-21 20:39:48 +0000
commit0f3f6485c8244000428c928fa0055e52e03c62f7 (patch)
tree6d94d5338e0b80b221c91b2dc1ea3247d008e9de /libgphoto2_port/usbdiskdirect/linux.c
parent9cf5eebe233f882ba1889b28fc975087c5eb4934 (diff)
downloadlibgphoto2-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/usbdiskdirect/linux.c')
-rw-r--r--libgphoto2_port/usbdiskdirect/linux.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/libgphoto2_port/usbdiskdirect/linux.c b/libgphoto2_port/usbdiskdirect/linux.c
index a3d1f70ef..46bb0d11a 100644
--- a/libgphoto2_port/usbdiskdirect/linux.c
+++ b/libgphoto2_port/usbdiskdirect/linux.c
@@ -245,9 +245,7 @@ gp_port_library_list (GPPortInfoList *list)
static int
gp_port_usbdiskdirect_init (GPPort *port)
{
- port->pl = calloc (1, sizeof (GPPortPrivateLibrary));
- if (!port->pl)
- return GP_ERROR_NO_MEMORY;
+ C_MEM (port->pl = calloc (1, sizeof (GPPortPrivateLibrary)));
port->pl->fd = -1;
@@ -421,10 +419,9 @@ gp_port_library_operations ()
{
GPPortOperations *ops;
- ops = malloc (sizeof (GPPortOperations));
+ ops = calloc (1, sizeof (GPPortOperations));
if (!ops)
return (NULL);
- memset (ops, 0, sizeof (GPPortOperations));
ops->init = gp_port_usbdiskdirect_init;
ops->exit = gp_port_usbdiskdirect_exit;