sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

commit c209e570976f7ba16ad2785f91db265b4f0821b8
parent 99a32820a148780d2f085f6b4bd6bd2011c365c2
Author: Matthew Sotoudeh <sotoudeh@cs.stanford.edu>
Date:   Fri, 29 Aug 2025 10:20:35 -0700

sort: Keep the "cap" field updated

it appears that a944b682a694b4e7900c94d6550845f8d52af574 forgot to
update the "cap" field upon resizing column arrays, making it always
0 and causing unnecessary allocations. This commit fixes that by
keeping the "cap" field updated.

Diffstat:
Msort.c | 1+
1 file changed, 1 insertion(+), 0 deletions(-)

diff --git a/sort.c b/sort.c @@ -126,6 +126,7 @@ columns(struct line *line, const struct keydef *kd, struct column *col) if (!(col->line.data) || col->cap < col->line.len + 1) { free(col->line.data); col->line.data = emalloc(col->line.len + 1); + col->cap = col->line.len + 1; } memcpy(col->line.data, start.data, col->line.len); col->line.data[col->line.len] = '\0';