log UPDATE add ERRMEM check macros
diff --git a/src/messages_client.c b/src/messages_client.c
index 5cd1165..5008865 100644
--- a/src/messages_client.c
+++ b/src/messages_client.c
@@ -53,10 +53,7 @@
}
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_ACT_GENERIC;
rpc->has_data = 1;
@@ -81,10 +78,7 @@
NC_CHECK_ARG_RET(NULL, xml_str, NULL);
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_ACT_GENERIC;
rpc->has_data = 0;
@@ -111,10 +105,7 @@
}
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_GETCONFIG;
rpc->source = source;
@@ -143,10 +134,7 @@
}
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_EDIT;
rpc->target = target;
@@ -177,10 +165,7 @@
}
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_COPY;
rpc->target = target;
@@ -209,10 +194,7 @@
NC_CHECK_ARG_RET(NULL, target, NULL);
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_DELETE;
rpc->target = target;
@@ -234,10 +216,7 @@
NC_CHECK_ARG_RET(NULL, target, NULL);
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_LOCK;
rpc->target = target;
@@ -253,10 +232,7 @@
NC_CHECK_ARG_RET(NULL, target, NULL);
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_UNLOCK;
rpc->target = target;
@@ -275,10 +251,7 @@
}
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_GET;
if (filter && (paramtype == NC_PARAMTYPE_DUP_AND_FREE)) {
@@ -300,10 +273,7 @@
NC_CHECK_ARG_RET(NULL, session_id, NULL);
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_KILL;
rpc->sid = session_id;
@@ -318,10 +288,7 @@
struct nc_rpc_commit *rpc;
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_COMMIT;
rpc->confirmed = confirmed;
@@ -347,10 +314,7 @@
struct nc_rpc *rpc;
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_DISCARD;
@@ -363,10 +327,7 @@
struct nc_rpc_cancel *rpc;
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_CANCEL;
if (persist_id && (paramtype == NC_PARAMTYPE_DUP_AND_FREE)) {
@@ -392,10 +353,7 @@
}
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_VALIDATE;
rpc->source = source;
@@ -417,10 +375,7 @@
NC_CHECK_ARG_RET(NULL, identifier, NULL);
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_GETSCHEMA;
if (paramtype == NC_PARAMTYPE_DUP_AND_FREE) {
@@ -455,10 +410,7 @@
}
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_SUBSCRIBE;
if (stream_name && (paramtype == NC_PARAMTYPE_DUP_AND_FREE)) {
@@ -502,10 +454,7 @@
}
rpc = calloc(1, sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->free = (paramtype == NC_PARAMTYPE_CONST ? 0 : 1);
rpc->type = NC_RPC_GETDATA;
@@ -526,16 +475,10 @@
}
if (origin_filter && (paramtype == NC_PARAMTYPE_DUP_AND_FREE)) {
rpc->origin_filter = malloc(origin_filter_count * sizeof *rpc->origin_filter);
- if (!rpc->origin_filter) {
- ERRMEM;
- goto error;
- }
+ NC_CHECK_ERRMEM_GOTO(!rpc->origin_filter,; , error);
for (i = 0; i < origin_filter_count; ++i) {
rpc->origin_filter[i] = strdup(origin_filter[i]);
- if (!rpc->origin_filter[i]) {
- ERRMEM;
- goto error;
- }
+ NC_CHECK_ERRMEM_GOTO(!rpc->origin_filter[i],; , error);
++rpc->origin_filter_count;
}
} else {
@@ -567,10 +510,7 @@
}
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_EDITDATA;
if (paramtype == NC_PARAMTYPE_DUP_AND_FREE) {
@@ -604,10 +544,7 @@
}
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_ESTABLISHSUB;
if (filter && (paramtype == NC_PARAMTYPE_DUP_AND_FREE)) {
@@ -654,10 +591,7 @@
}
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_MODIFYSUB;
rpc->id = id;
@@ -684,10 +618,7 @@
NC_CHECK_ARG_RET(NULL, id, NULL);
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_DELETESUB;
rpc->id = id;
@@ -703,10 +634,7 @@
NC_CHECK_ARG_RET(NULL, id, NULL);
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_KILLSUB;
rpc->id = id;
@@ -729,10 +657,7 @@
}
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_ESTABLISHPUSH;
if (paramtype == NC_PARAMTYPE_DUP_AND_FREE) {
@@ -783,10 +708,7 @@
}
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_ESTABLISHPUSH;
if (paramtype == NC_PARAMTYPE_DUP_AND_FREE) {
@@ -842,10 +764,7 @@
}
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_MODIFYPUSH;
rpc->id = id;
@@ -891,10 +810,7 @@
}
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_MODIFYPUSH;
rpc->id = id;
@@ -928,10 +844,7 @@
NC_CHECK_ARG_RET(NULL, id, NULL);
rpc = malloc(sizeof *rpc);
- if (!rpc) {
- ERRMEM;
- return NULL;
- }
+ NC_CHECK_ERRMEM_RET(!rpc, NULL);
rpc->type = NC_RPC_RESYNCSUB;
rpc->id = id;