[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Use xzalloc instead of xmalloc and memset
From: |
John Darrington |
Subject: |
[PATCH] Use xzalloc instead of xmalloc and memset |
Date: |
Thu, 16 Jan 2020 10:25:43 +0100 |
---
ChangeLog | 9 +++++++++
src/pk-repl.c | 3 +--
src/pkl-ast.c | 6 ++----
src/pkl-env.c | 5 +----
src/pkl-parser.c | 3 +--
src/pkl.c | 4 +---
src/pvm.c | 3 +--
7 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a982d56e..8863ced4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2020-01-18 John Darrington <address@hidden>
+
+ * src/pk-repl.c (poke_getc): Use xzalloc instead of xmalloc.
+ * src/pkl-ast.c (pkl_ast_make_node): ditto
+ * src/pkl-env.c (pkl_env_new): ditto
+ * src/pkl-parser.c (pkl_parser_init): ditto
+ * src/pkl.c (pkl_new): ditto
+ * src/pvm.c (pvm_init): ditto
+
2020-01-16 Darshit Shah <address@hidden>
* bootstrap.conf: Set --skip-po to be the default option.
diff --git a/src/pk-repl.c b/src/pk-repl.c
index b5651c1e..574b9935 100644
--- a/src/pk-repl.c
+++ b/src/pk-repl.c
@@ -74,10 +74,9 @@ poke_completion_function (const char *x, int state)
static int
poke_getc (FILE *stream)
{
- char *line_to_point = xmalloc (rl_point + 1);
+ char *line_to_point = xzalloc (rl_point + 1);
int end = rl_point ? rl_point - 1 : 0;
strncpy (line_to_point, rl_line_buffer, end);
- line_to_point[end] = '\0';
char *tok = strtok (line_to_point, "\t ");
if (rl_completion_entry_function == poke_completion_function)
diff --git a/src/pkl-ast.c b/src/pkl-ast.c
index 5f775fd1..3d03e6ff 100644
--- a/src/pkl-ast.c
+++ b/src/pkl-ast.c
@@ -40,8 +40,7 @@ pkl_ast_make_node (pkl_ast ast,
{
pkl_ast_node node;
- node = xmalloc (sizeof (union pkl_ast_node));
- memset (node, 0, sizeof (union pkl_ast_node));
+ node = xzalloc (sizeof (union pkl_ast_node));
PKL_AST_AST (node) = ast;
PKL_AST_CODE (node) = code;
PKL_AST_UID (node) = ast->uid++;
@@ -2041,8 +2040,7 @@ pkl_ast_init (void)
struct pkl_ast *ast;
/* Allocate a new AST and initialize it to 0. */
- ast = xmalloc (sizeof (struct pkl_ast));
- memset (ast, 0, sizeof (struct pkl_ast));
+ ast = xzalloc (sizeof (struct pkl_ast));
return ast;
}
diff --git a/src/pkl-env.c b/src/pkl-env.c
index 3c30ba3e..ecde48d9 100644
--- a/src/pkl-env.c
+++ b/src/pkl-env.c
@@ -127,10 +127,7 @@ register_decl (pkl_hash hash_table,
pkl_env
pkl_env_new ()
{
- pkl_env env = xmalloc (sizeof (struct pkl_env));
-
- memset (env, 0, sizeof (struct pkl_env));
- return env;
+ return xzalloc (sizeof (struct pkl_env));
}
void
diff --git a/src/pkl-parser.c b/src/pkl-parser.c
index 6dbe3798..6b4ebaa2 100644
--- a/src/pkl-parser.c
+++ b/src/pkl-parser.c
@@ -34,8 +34,7 @@ pkl_parser_init (void)
{
struct pkl_parser *parser;
- parser = xmalloc (sizeof (struct pkl_parser));
- memset (parser, 0, sizeof (struct pkl_parser));
+ parser = xzalloc (sizeof (struct pkl_parser));
pkl_tab_lex_init (&(parser->scanner));
pkl_tab_set_extra (parser, parser->scanner);
diff --git a/src/pkl.c b/src/pkl.c
index a522b907..99af544a 100644
--- a/src/pkl.c
+++ b/src/pkl.c
@@ -63,9 +63,7 @@ pkl_compiler
pkl_new ()
{
pkl_compiler compiler
- = xmalloc (sizeof (struct pkl_compiler));
-
- memset (compiler, 0, sizeof (struct pkl_compiler));
+ = xzalloc (sizeof (struct pkl_compiler));
/* Create the top-level compile-time environment. This will be used
for as long as the incremental compiler lives. */
diff --git a/src/pvm.c b/src/pvm.c
index a0d5f9d4..14389cf8 100644
--- a/src/pvm.c
+++ b/src/pvm.c
@@ -50,8 +50,7 @@ struct pvm
pvm
pvm_init (void)
{
- pvm apvm = xmalloc (sizeof (struct pvm));
- memset (apvm, 0, sizeof (struct pvm));
+ pvm apvm = xzalloc (sizeof (struct pvm));
/* Initialize the memory allocation subsystem. */
pvm_alloc_initialize ();
--
2.11.0
- [PATCH] Use xzalloc instead of xmalloc and memset,
John Darrington <=