2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Add and use semantic patch to replace isc_mem_get/allocate+memset

Add new semantic patch to replace the straightfoward uses of:

  ptr = isc_mem_{get,allocate}(..., size);
  memset(ptr, 0, size);

with the new API call:

  ptr = isc_mem_{get,allocate}x(..., size, ISC_MEM_ZERO);
This commit is contained in:
Ondřej Surý
2022-06-03 12:36:24 +02:00
parent dbf5672f32
commit c1d26b53eb
40 changed files with 124 additions and 172 deletions

View File

@@ -125,8 +125,7 @@ load_plugin(isc_mem_t *mctx, const char *modpath, ns_plugin_t **pluginp) {
REQUIRE(pluginp != NULL && *pluginp == NULL);
plugin = isc_mem_get(mctx, sizeof(*plugin));
memset(plugin, 0, sizeof(*plugin));
plugin = isc_mem_getx(mctx, sizeof(*plugin), ISC_MEM_ZERO);
isc_mem_attach(mctx, &plugin->mctx);
plugin->modpath = isc_mem_strdup(plugin->mctx, modpath);
@@ -318,8 +317,7 @@ ns_hook_add(ns_hooktable_t *hooktable, isc_mem_t *mctx,
REQUIRE(hookpoint < NS_HOOKPOINTS_COUNT);
REQUIRE(hook != NULL);
copy = isc_mem_get(mctx, sizeof(*copy));
memset(copy, 0, sizeof(*copy));
copy = isc_mem_getx(mctx, sizeof(*copy), ISC_MEM_ZERO);
copy->action = hook->action;
copy->action_data = hook->action_data;
@@ -335,8 +333,7 @@ ns_plugins_create(isc_mem_t *mctx, ns_plugins_t **listp) {
REQUIRE(listp != NULL && *listp == NULL);
plugins = isc_mem_get(mctx, sizeof(*plugins));
memset(plugins, 0, sizeof(*plugins));
plugins = isc_mem_getx(mctx, sizeof(*plugins), ISC_MEM_ZERO);
ISC_LIST_INIT(*plugins);
*listp = plugins;