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);
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);
dns_view_detach(&inst->view);
dns_zonemgr_detach(&inst->zmgr);
- MEM_PUT_AND_DETACH(inst);
+ isc_mem_putanddetach(&inst->mctx, inst, sizeof(*inst));
}
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)))