浏览代码

convert to zalloc

tags/v0.9.3
Holger Lubitz 17 年前
父节点
当前提交
75ff85441b
共有 1 个文件被更改,包括 3 次插入6 次删除
  1. 3
    6
      src/core/resolv.c

+ 3
- 6
src/core/resolv.c 查看文件

@@ -116,10 +116,9 @@ static int numeric_resolv ( struct resolv_interface *resolv,
116 116
 	struct sockaddr_in *sin;
117 117
 
118 118
 	/* Allocate and initialise structure */
119
-	numeric = malloc ( sizeof ( *numeric ) );
119
+	numeric = zalloc ( sizeof ( *numeric ) );
120 120
 	if ( ! numeric )
121 121
 		return -ENOMEM;
122
-	memset ( numeric, 0, sizeof ( *numeric ) );
123 122
 	resolv_init ( &numeric->resolv, &null_resolv_ops, &numeric->refcnt );
124 123
 	process_init ( &numeric->process, numeric_step, &numeric->refcnt );
125 124
 	memcpy ( &numeric->sa, sa, sizeof ( numeric->sa ) );
@@ -258,10 +257,9 @@ int resolv ( struct resolv_interface *resolv, const char *name,
258 257
 	int rc;
259 258
 
260 259
 	/* Allocate and initialise structure */
261
-	mux = malloc ( sizeof ( *mux ) + name_len );
260
+	mux = zalloc ( sizeof ( *mux ) + name_len );
262 261
 	if ( ! mux )
263 262
 		return -ENOMEM;
264
-	memset ( mux, 0, sizeof ( *mux ) );
265 263
 	resolv_init ( &mux->parent, &null_resolv_ops, &mux->refcnt );
266 264
 	resolv_init ( &mux->child, &resolv_mux_child_ops, &mux->refcnt );
267 265
 	mux->resolver = resolvers;
@@ -388,10 +386,9 @@ int xfer_open_named_socket ( struct xfer_interface *xfer, int semantics,
388 386
 	int rc;
389 387
 
390 388
 	/* Allocate and initialise structure */
391
-	named = malloc ( sizeof ( *named ) );
389
+	named = zalloc ( sizeof ( *named ) );
392 390
 	if ( ! named )
393 391
 		return -ENOMEM;
394
-	memset ( named, 0, sizeof ( *named ) );
395 392
 	xfer_init ( &named->xfer, &named_xfer_ops, &named->refcnt );
396 393
 	resolv_init ( &named->resolv, &named_resolv_ops, &named->refcnt );
397 394
 	named->semantics = semantics;

正在加载...
取消
保存