projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
b25a043
)
oracle plugin: malloc + memset -> calloc
author
Ruben Kerkhof
<ruben@rubenkerkhof.com>
Fri, 1 Apr 2016 16:03:50 +0000
(18:03 +0200)
committer
Ruben Kerkhof
<ruben@rubenkerkhof.com>
Fri, 1 Apr 2016 16:03:50 +0000
(18:03 +0200)
src/oracle.c
patch
|
blob
|
history
diff --git
a/src/oracle.c
b/src/oracle.c
index
fedefd0
..
3e4653d
100644
(file)
--- a/
src/oracle.c
+++ b/
src/oracle.c
@@
-198,13
+198,12
@@
static int o_config_add_database (oconfig_item_t *ci) /* {{{ */
return (-1);
}
return (-1);
}
- db =
malloc (
sizeof (*db));
+ db =
calloc (1,
sizeof (*db));
if (db == NULL)
{
if (db == NULL)
{
- ERROR ("oracle plugin:
m
alloc failed.");
+ ERROR ("oracle plugin:
c
alloc failed.");
return (-1);
}
return (-1);
}
- memset (db, 0, sizeof (*db));
db->name = NULL;
db->host = NULL;
db->connect_id = NULL;
db->name = NULL;
db->host = NULL;
db->connect_id = NULL;
@@
-502,13
+501,12
@@
static int o_read_database_query (o_database_t *db, /* {{{ */
#define ALLOC_OR_FAIL(ptr, ptr_size) \
do { \
size_t alloc_size = (size_t) ((ptr_size)); \
#define ALLOC_OR_FAIL(ptr, ptr_size) \
do { \
size_t alloc_size = (size_t) ((ptr_size)); \
- (ptr) =
malloc (
alloc_size); \
+ (ptr) =
calloc (1,
alloc_size); \
if ((ptr) == NULL) { \
FREE_ALL; \
if ((ptr) == NULL) { \
FREE_ALL; \
- ERROR ("oracle plugin: o_read_database_query:
m
alloc failed."); \
+ ERROR ("oracle plugin: o_read_database_query:
c
alloc failed."); \
return (-1); \
} \
return (-1); \
} \
- memset ((ptr), 0, alloc_size); \
} while (0)
/* Initialize everything to NULL so the above works. */
} while (0)
/* Initialize everything to NULL so the above works. */