Provide an alternative CTDB_NO_MEMORY_NULL() for functions which return a pointer
authorAlexander Bokovoy <ab@samba.org>
Fri, 1 Dec 2006 09:26:21 +0000 (12:26 +0300)
committerAlexander Bokovoy <ab@samba.org>
Fri, 1 Dec 2006 09:26:21 +0000 (12:26 +0300)
(This used to be ctdb commit 51c79e19df777fb53a5c210efc1c9d3159059de3)

ctdb/common/ctdb_call.c
ctdb/include/ctdb_private.h

index c6dff1e5c0da382109ffe1232857b20c7ee00c62..a2219403a2509ff2b35a724c4acad7962e2fa3b5 100644 (file)
@@ -186,7 +186,7 @@ struct ctdb_call_state *ctdb_call_local_send(struct ctdb_context *ctdb,
        int ret;
 
        state = talloc_zero(ctdb, struct ctdb_call_state);
-       CTDB_NO_MEMORY(ctdb, state);
+       CTDB_NO_MEMORY_NULL(ctdb, state);
 
        state->state = CTDB_CALL_DONE;
        state->node = ctdb->nodes[ctdb->vnn];
@@ -213,11 +213,11 @@ struct ctdb_call_state *ctdb_call_send(struct ctdb_context *ctdb,
        }
 
        state = talloc_zero(ctdb, struct ctdb_call_state);
-       CTDB_NO_MEMORY(ctdb, state);
+       CTDB_NO_MEMORY_NULL(ctdb, state);
 
        len = sizeof(*state->c) + key.dsize + (call_data?call_data->dsize:0);
        state->c = talloc_size(ctdb, len);
-       CTDB_NO_MEMORY(ctdb, state->c);
+       CTDB_NO_MEMORY_NULL(ctdb, state->c);
 
        state->c->hdr.length    = len;
        state->c->hdr.operation = CTDB_REQ_CALL;
index e2f851749de1ec54445bc133d9f817fea05c4165..32f258b2bf801c91c89b052fbf706bcc75801903 100644 (file)
@@ -94,6 +94,10 @@ struct ctdb_context {
           ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
          return -1; }} while (0)
 
+#define CTDB_NO_MEMORY_NULL(ctdb, p) do { if (!(p)) { \
+          ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
+         return NULL; }} while (0)
+
 /* arbitrary maximum timeout for ctdb operations */
 #define CTDB_REQ_TIMEOUT 10