* src/od.c (dump): Only use a single memory block
when there is no need to compare against the previous block.
---
 NEWS     | 4 ++++
 src/od.c | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 3a731f520..b69e20eab 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,10 @@ GNU coreutils NEWS                                    -*- 
outline -*-
   outputting to a terminal.  The previous release enabled this for all
   outputs by default, requiring setting QUOTING_STYLE=literal to disable.
 
+** Improvements
+
+  'od' allocates half the memory when is specified -v,--output-duplicates.
+
 
 * Noteworthy changes in release 9.12 (2026-09-14) [stable]
 
diff --git a/src/od.c b/src/od.c
index 891037580..23d92543e 100644
--- a/src/od.c
+++ b/src/od.c
@@ -1519,8 +1519,8 @@ dump (void)
   bool ok = true;
   idx_t n_bytes_read;
 
-  block[0] = xinmalloc (2, bytes_per_block);
-  block[1] = block[0] + bytes_per_block;
+  block[0] = xinmalloc (1 + abbreviate_duplicate_blocks, bytes_per_block);
+  block[1] = block[0] + abbreviate_duplicate_blocks * bytes_per_block;
 
   intmax_t current_offset = n_bytes_to_skip;
 
-- 
2.55.0


Reply via email to