]> Savannah Git Hosting - gnulib.git/commit
trim: do not over-allocate result
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 27 Aug 2023 06:19:12 +0000 (23:19 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 27 Aug 2023 06:34:02 +0000 (23:34 -0700)
commit5f27affb42337dc605a9a59f1c6a99516cd9747a
tree3616a0efc3140c3e70f5f211bc1d7e6d231999e1
parentc2925f5f11158d9892f78c4316c79e6e1ac1fc32
trim: do not over-allocate result

* lib/trim.c: Include mbuiterf.h, not mbiterf.h, since we no
longer compute strlen at first.
(trim2): Do not over-allocate result and then trim the parts we
don’t want.  Instead, skip unwanted input before allocating,
so that the result is just the right size.  Use mempcpy
instead of memmove.  Simplify.
* modules/trim (Depends-on): Remove mbiterf, memmove, strdup, xalloc.
Add mbuiterf, mempcpy, xalloc-die.
ChangeLog
lib/trim.c
modules/trim