[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Gavin D. Smith |
Date: |
Tue, 11 Apr 2023 15:18:41 -0400 (EDT) |
branch: master
commit 068d59209c65bbc0b7338bc4534e97e1890f37d9
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Tue Apr 11 20:14:57 2023 +0100
* tp/Texinfo/XS/parsetexi.c (alloc_and_zero): New function
to wrap calloc. Use for obstack_chunk_alloc definition.
(new_element): Remove explicit initialisation code.
---
ChangeLog | 6 ++++++
tp/Texinfo/XS/parsetexi/tree.c | 26 +++++++++-----------------
2 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index cd5942f7c5..030dccfa83 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-04-11 Gavin Smith <gavinsmith0123@gmail.com>
+
+ * tp/Texinfo/XS/parsetexi.c (alloc_and_zero): New function
+ to wrap calloc. Use for obstack_chunk_alloc definition.
+ (new_element): Remove explicit initialisation code.
+
2023-04-10 Gavin Smith <gavinsmith0123@gmail.com>
* tp/Texinfo/XS/parsetexi/tree_types.h (ELEMENT):
diff --git a/tp/Texinfo/XS/parsetexi/tree.c b/tp/Texinfo/XS/parsetexi/tree.c
index 4baffb0be1..5b6d2769aa 100644
--- a/tp/Texinfo/XS/parsetexi/tree.c
+++ b/tp/Texinfo/XS/parsetexi/tree.c
@@ -76,7 +76,13 @@
static struct obstack obs_element;
static int *obs_element_first = 0;
-#define obstack_chunk_alloc malloc
+static void *
+alloc_and_zero (size_t size)
+{
+ return calloc (1, size);
+}
+
+#define obstack_chunk_alloc alloc_and_zero
#define obstack_chunk_free free
void
@@ -101,24 +107,10 @@ new_element (enum element_type type)
//element_counter++;
- /* Zero all elements */
- memset (e, 0, sizeof (*e));
+ /* alloc_element zeroes *e. We assume null pointers have bit representation
+ of all zeroes. */
e->type = type;
- e->cmd = CM_NONE;
- e->args.list = 0;
- e->args.space = 0;
- e->args.number = 0;
- e->contents.list = 0;
- e->contents.space = 0;
- e->contents.number = 0;
- e->parent = 0;
-
- e->extra_info.info = 0;
- e->info_info.info = 0;
-
- e->source_mark_list.space = 0;
- e->source_mark_list.number = 0;
return e;
}