]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Get rid of unnecessary macros in the system test dyndb driver
authorTony Finch <fanf@isc.org>
Mon, 12 Jun 2023 11:08:07 +0000 (12:08 +0100)
committerOndřej Surý <ondrej@isc.org>
Wed, 23 Aug 2023 12:49:15 +0000 (14:49 +0200)
CHECKED_MEM_GET and ZERO_PTR are built-in features of isc_mem.

bin/tests/system/dyndb/driver/db.c
bin/tests/system/dyndb/driver/instance.c
bin/tests/system/dyndb/driver/util.h

index d380511e7e0969575006a8662d71a4f732877a19..cadd3d02c2cb2bb589990ef49aa2b2fdd2b27eb4 100644 (file)
@@ -606,8 +606,7 @@ create_db(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
 
        a_addr.s_addr = 0x0100007fU;
 
-       CHECKED_MEM_GET_PTR(mctx, sampledb);
-       ZERO_PTR(sampledb);
+       sampledb = isc_mem_getx(mctx, sizeof(*sampledb), ISC_MEM_ZERO);
 
        isc_mem_attach(mctx, &sampledb->common.mctx);
        dns_name_init(&sampledb->common.origin, NULL);
index 4ce0d1b31bec510001015e0d324b46837df203c4..af09f3551b74dba5dd6b3c0269206efd47c6750a 100644 (file)
@@ -111,12 +111,11 @@ new_sample_instance(isc_mem_t *mctx, const char *db_name, int argc, char **argv,
                    const dns_dyndbctx_t *dctx,
                    sample_instance_t **sample_instp) {
        isc_result_t result;
-       sample_instance_t *inst = NULL;
 
        REQUIRE(sample_instp != NULL && *sample_instp == NULL);
 
-       CHECKED_MEM_GET_PTR(mctx, inst);
-       ZERO_PTR(inst);
+       sample_instance_t *inst = isc_mem_getx(mctx, sizeof(*inst),
+                                              ISC_MEM_ZERO);
        isc_mem_attach(mctx, &inst->mctx);
 
        inst->db_name = isc_mem_strdup(mctx, db_name);
@@ -225,5 +224,5 @@ destroy_sample_instance(sample_instance_t **instp) {
        dns_view_detach(&inst->view);
        dns_zonemgr_detach(&inst->zmgr);
 
-       MEM_PUT_AND_DETACH(inst);
+       isc_mem_putanddetach(&inst->mctx, inst, sizeof(*inst));
 }
index d59a7fd6ea1b1c4612eee78ed5a0beb27b294428..e3ccedfe7e8f0dc09bdacb58727738fb5f7fc32a 100644 (file)
                if (result != ISC_R_SUCCESS) \
                        goto cleanup;        \
        } while (0)
-
-#define CHECKED_MEM_GET(m, target_ptr, s)                      \
-       do {                                                   \
-               (target_ptr) = isc_mem_get((m), (s));          \
-               if ((target_ptr) == NULL) {                    \
-                       result = ISC_R_NOMEMORY;               \
-                       log_error("Memory allocation failed"); \
-                       goto cleanup;                          \
-               }                                              \
-       } while (0)
-
-#define CHECKED_MEM_GET_PTR(m, target_ptr) \
-       CHECKED_MEM_GET(m, target_ptr, sizeof(*(target_ptr)))
-
-#define CHECKED_MEM_STRDUP(m, source, target)                  \
-       do {                                                   \
-               (target) = isc_mem_strdup((m), (source));      \
-               if ((target) == NULL) {                        \
-                       result = ISC_R_NOMEMORY;               \
-                       log_error("Memory allocation failed"); \
-                       goto cleanup;                          \
-               }                                              \
-       } while (0)
-
-#define ZERO_PTR(ptr) memset((ptr), 0, sizeof(*(ptr)))
-
-#define MEM_PUT_AND_DETACH(target_ptr)                        \
-       isc_mem_putanddetach(&(target_ptr)->mctx, target_ptr, \
-                            sizeof(*(target_ptr)))