ctdb-protocol: Move tdb_data marshalling code
authorAmitay Isaacs <amitay@gmail.com>
Mon, 31 Jul 2017 06:48:58 +0000 (16:48 +1000)
committerMartin Schwenke <martins@samba.org>
Wed, 30 Aug 2017 12:59:22 +0000 (14:59 +0200)
There is no change in the code.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/protocol/protocol_private.h
ctdb/protocol/protocol_types.c

index 0816bd15d99887af10113362b3f54c46135ee4dc..c8b9d9c30cfa68b6a47fd8828a3751a585405464 100644 (file)
@@ -89,6 +89,11 @@ int ctdb_padding_pull(uint8_t *buf, size_t buflen, int count, size_t *npull);
  * From protocol/protocol_types.c
  */
 
+size_t ctdb_tdb_data_len(TDB_DATA data);
+void ctdb_tdb_data_push(TDB_DATA data, uint8_t *buf);
+int ctdb_tdb_data_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
+                      TDB_DATA *out);
+
 size_t ctdb_statistics_len(struct ctdb_statistics *stats);
 void ctdb_statistics_push(struct ctdb_statistics *stats, uint8_t *buf);
 int ctdb_statistics_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
@@ -273,11 +278,6 @@ void ctdb_srvid_message_push(struct ctdb_srvid_message *msg, uint8_t *buf);
 int ctdb_srvid_message_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
                            struct ctdb_srvid_message **out);
 
-size_t ctdb_tdb_data_len(TDB_DATA data);
-void ctdb_tdb_data_push(TDB_DATA data, uint8_t *buf);
-int ctdb_tdb_data_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
-                      TDB_DATA *out);
-
 size_t ctdb_disable_message_len(struct ctdb_disable_message *disable);
 void ctdb_disable_message_push(struct ctdb_disable_message *disable,
                               uint8_t *buf);
index 936f799d087e6a8f1000f27baca17b9e6731cc75..85a661db8fe451ae02fe36508c12e552ccbb794f 100644 (file)
 #include "protocol_private.h"
 #include "protocol_api.h"
 
+size_t ctdb_tdb_data_len(TDB_DATA data)
+{
+       return data.dsize;
+}
+
+void ctdb_tdb_data_push(TDB_DATA data, uint8_t *buf)
+{
+       if (data.dsize > 0) {
+               memcpy(buf, data.dptr, data.dsize);
+       }
+}
+
+int ctdb_tdb_data_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
+                      TDB_DATA *out)
+{
+       TDB_DATA data;
+
+       data.dsize = buflen;
+       if (data.dsize > 0) {
+               data.dptr = talloc_memdup(mem_ctx, buf, buflen);
+               if (data.dptr == NULL) {
+                       return ENOMEM;
+               }
+       } else {
+               data.dptr = NULL;
+       }
+
+       *out = data;
+       return 0;
+}
+
 size_t ctdb_statistics_len(struct ctdb_statistics *stats)
 {
        return sizeof(struct ctdb_statistics);
@@ -2213,37 +2244,6 @@ int ctdb_disable_message_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
        return 0;
 }
 
-size_t ctdb_tdb_data_len(TDB_DATA data)
-{
-       return data.dsize;
-}
-
-void ctdb_tdb_data_push(TDB_DATA data, uint8_t *buf)
-{
-       if (data.dsize > 0) {
-               memcpy(buf, data.dptr, data.dsize);
-       }
-}
-
-int ctdb_tdb_data_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
-                      TDB_DATA *out)
-{
-       TDB_DATA data;
-
-       data.dsize = buflen;
-       if (data.dsize > 0) {
-               data.dptr = talloc_memdup(mem_ctx, buf, buflen);
-               if (data.dptr == NULL) {
-                       return ENOMEM;
-               }
-       } else {
-               data.dptr = NULL;
-       }
-
-       *out = data;
-       return 0;
-}
-
 size_t ctdb_server_id_len(struct ctdb_server_id *sid)
 {
        return sizeof(struct ctdb_server_id);