summaryrefslogtreecommitdiff
path: root/src/pch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pch.c')
-rw-r--r--src/pch.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/pch.c b/src/pch.c
index 145c4ef..33facd9 100644
--- a/src/pch.c
+++ b/src/pch.c
@@ -158,20 +158,19 @@ open_patch_file (char const *filename)
if (p_filesize != (file_offset) p_filesize)
fatal ("patch file is too long");
next_intuit_at (file_pos, 1);
- set_hunkmax();
}
/* Make sure our dynamically realloced tables are malloced to begin with. */
-void
+static void
set_hunkmax (void)
{
if (!p_line)
- p_line = (char **) malloc (hunkmax * sizeof *p_line);
+ p_line = (char **) xmalloc (hunkmax * sizeof *p_line);
if (!p_len)
- p_len = (size_t *) malloc (hunkmax * sizeof *p_len);
+ p_len = (size_t *) xmalloc (hunkmax * sizeof *p_len);
if (!p_Char)
- p_Char = malloc (hunkmax * sizeof *p_Char);
+ p_Char = xmalloc (hunkmax * sizeof *p_Char);
}
/* Enlarge the arrays containing the current hunk of patch. */
@@ -1173,6 +1172,8 @@ another_hunk (enum diff difftype, bool rev)
char numbuf2[LINENUM_LENGTH_BOUND + 1];
char numbuf3[LINENUM_LENGTH_BOUND + 1];
+ set_hunkmax();
+
while (p_end >= 0) {
if (p_end == p_efake)
p_end = p_bfake; /* don't free twice */