[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 04/17] maint: zalloc → xzalloc
From: |
Paul Eggert |
Subject: |
[PATCH 04/17] maint: zalloc → xzalloc |
Date: |
Sun, 22 Aug 2021 14:02:53 -0700 |
* src/util.c (zalloc): Remove. All uses replaced
by xzalloc, which means the same thing.
---
src/analyze.c | 8 ++++----
src/diff.h | 3 ---
src/io.c | 2 +-
src/util.c | 10 ----------
4 files changed, 5 insertions(+), 18 deletions(-)
diff --git a/src/analyze.c b/src/analyze.c
index a5e4bdc..e11f7d4 100644
--- a/src/analyze.c
+++ b/src/analyze.c
@@ -67,7 +67,7 @@ discard_confusing_lines (struct file_data filevec[])
/* Set up equiv_count[F][I] as the number of lines in file F
that fall in equivalence class I. */
- p = zalloc (filevec[0].equiv_max * (2 * sizeof *p));
+ p = xcalloc (filevec[0].equiv_max, 2 * sizeof *p);
equiv_count[0] = p;
equiv_count[1] = p + filevec[0].equiv_max;
@@ -78,8 +78,8 @@ discard_confusing_lines (struct file_data filevec[])
/* Set up tables of which lines are going to be discarded. */
- discarded[0] = zalloc (filevec[0].buffered_lines
- + filevec[1].buffered_lines);
+ discarded[0] = xzalloc (filevec[0].buffered_lines
+ + filevec[1].buffered_lines);
discarded[1] = discarded[0] + filevec[0].buffered_lines;
/* Mark to be discarded each line that matches no line of the other file.
@@ -542,7 +542,7 @@ diff_2_files (struct comparison *cmp)
Allocate an extra element, always 0, at each end of each vector. */
size_t s = cmp->file[0].buffered_lines + cmp->file[1].buffered_lines + 4;
- char *flag_space = zalloc (s);
+ char *flag_space = xzalloc (s);
cmp->file[0].changed = flag_space + 1;
cmp->file[1].changed = flag_space + cmp->file[0].buffered_lines + 3;
diff --git a/src/diff.h b/src/diff.h
index c469371..a51b9d2 100644
--- a/src/diff.h
+++ b/src/diff.h
@@ -389,9 +389,6 @@ extern bool lines_differ (char const *, char const *)
_GL_ATTRIBUTE_PURE;
extern lin translate_line_number (struct file_data const *, lin);
extern struct change *find_change (struct change *);
extern struct change *find_reverse_change (struct change *);
-extern void *zalloc (size_t)
- _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
- _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
extern enum changes analyze_hunk (struct change *, lin *, lin *, lin *, lin *);
extern void begin_output (void);
extern void debug_script (struct change *);
diff --git a/src/io.c b/src/io.c
index 1f0e040..77fc070 100644
--- a/src/io.c
+++ b/src/io.c
@@ -806,7 +806,7 @@ read_files (struct file_data filevec[], bool pretend_binary)
nbuckets = ((size_t) 1 << i) - prime_offset[i];
if (PTRDIFF_MAX / sizeof *buckets <= nbuckets)
xalloc_die ();
- buckets = zalloc ((nbuckets + 1) * sizeof *buckets);
+ buckets = xcalloc (nbuckets + 1, sizeof *buckets);
buckets++;
for (i = 0; i < 2; i++)
diff --git a/src/util.c b/src/util.c
index 4348757..b5efb59 100644
--- a/src/util.c
+++ b/src/util.c
@@ -1546,16 +1546,6 @@ concat (char const *s1, char const *s2, char const *s3)
sprintf (new, "%s%s%s", s1, s2, s3);
return new;
}
-
-/* Yield a new block of SIZE bytes, initialized to zero. */
-
-void *
-zalloc (size_t size)
-{
- void *p = xmalloc (size);
- memset (p, 0, size);
- return p;
-}
void
debug_script (struct change *sp)
--
2.31.1
- [PATCH 01/17] build: update gnulib submodule to latest, Paul Eggert, 2021/08/22
- [PATCH 06/17] maint: omit unused function if not debugging, Paul Eggert, 2021/08/22
- [PATCH 12/17] diff3: simplify process_diff, Paul Eggert, 2021/08/22
- [PATCH 09/17] diff: remove printint, Paul Eggert, 2021/08/22
- [PATCH 14/17] diff: use mempcpy, Paul Eggert, 2021/08/22
- [PATCH 08/17] diff: remove INT_MAX limit on -F/-p searches, Paul Eggert, 2021/08/22
- [PATCH 03/17] diff3: suppress -fanalyzer alarms, Paul Eggert, 2021/08/22
- [PATCH 16/17] maint: refactor integer overflow checking, Paul Eggert, 2021/08/22
- [PATCH 04/17] maint: zalloc → xzalloc,
Paul Eggert <=
- [PATCH 13/17] sdiff: fix unlikely memory leak, Paul Eggert, 2021/08/22
- [PATCH 02/17] maint: remove January workaround for Gnulib issue, Paul Eggert, 2021/08/22
- [PATCH 17/17] diff: add integer overflow checking, Paul Eggert, 2021/08/22
- [PATCH 10/17] maint: lint → GCC_LINT, Paul Eggert, 2021/08/22
- [PATCH 05/17] maint: remove prepargs, Paul Eggert, 2021/08/22
- [PATCH 07/17] maint: .gitignore updates, Paul Eggert, 2021/08/22
- [PATCH 11/17] maint: modernize IF_LINT for GCC 11.2.1, Paul Eggert, 2021/08/22
- [PATCH 15/17] diff: avoid sprintf %s, Paul Eggert, 2021/08/22