[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-tar] [PATCH] tar: simplify code in system.c
From: |
Sergey Poznyakoff |
Subject: |
Re: [Bug-tar] [PATCH] tar: simplify code in system.c |
Date: |
Wed, 20 Feb 2013 16:28:45 +0300 |
Pavel Raiskup <address@hidden> ha escrit:
> Move the xexec function into #ifndef MSDOS part of file.
Yes, that's reasonable.
> * system.c (try_exec): New function - modified previous xexec.
This will cause a memory leak and imply unnecessary memory
reallocations.
What happens here is:
487 if (wordsplit (p, &ws, wsflags))
488 FATAL_ERROR ((0, 0, _("cannot split string '%s': %s"),
489 p, wordsplit_strerror (&ws)));
490 wsflags |= WRDSF_REUSE;
after the first call to wordsplit the WRDSF_REUSE flag is set, which
forces wordsplit to reuse already allocated memory on the next iteration
of the loop.
If using the proposed try_exec, then (1) the memory allocated by each
call to wordsplit is never freed, (2) an extra call to xmalloc causes
unnecessary memory allocation, which is never freed as well, and (3)
each subsequent call to wordsplit allocates new blocks of memory instead
of reusing the previously allocated ones. Besides, shifting a memory
array and adding an extra element is much faster than allocating a new
block of memory for the sole purpose of tucking an extra "-d" in it.
Regards,
Sergey
- Re: [Bug-tar] [PATCH 0/1] Notes for wordsplit (was: Allow tar to usecommand for compressing consisiting of multiple words.), (continued)
- Re: [Bug-tar] [PATCH 0/1] Notes for wordsplit (was: Allow tar to usecommand for compressing consisiting of multiple words.), Pavel Raiskup, 2013/02/20
- Re: [Bug-tar] [PATCH 0/1] Notes for wordsplit (was: Allow tar to usecommand for compressing consisiting of multiple words.), Sergey Poznyakoff, 2013/02/20
- Re: [Bug-tar] [PATCH 0/1] Notes for wordsplit (was: Allow tar to usecommand for compressing consisiting of multiple words.), Pavel Raiskup, 2013/02/20
- Re: [Bug-tar] [PATCH 0/1] Notes for wordsplit (was: Allow tar to usecommand for compressing consisiting of multiple words.), Sergey Poznyakoff, 2013/02/20
- Re: [Bug-tar] [PATCH 0/1] Notes for wordsplit (was: Allow tar to usecommand for compressing consisiting of multiple words.), Paul Eggert, 2013/02/20
- Re: [Bug-tar] [PATCH 0/1] Notes for wordsplit (was: Allow tar to usecommand for compressing consisiting of multiple words.), Sergey Poznyakoff, 2013/02/20
- Re: [Bug-tar] [PATCH 0/1] Notes for wordsplit, Eric Blake, 2013/02/20
- Re: [Bug-tar] [PATCH 0/1] Notes for wordsplit, Joerg Schilling, 2013/02/21
- Re: [Bug-tar] [PATCH 0/1] Notes for wordsplit, Paul Eggert, 2013/02/21
- [Bug-tar] [PATCH] tar: simplify code in system.c, Pavel Raiskup, 2013/02/20
- Re: [Bug-tar] [PATCH] tar: simplify code in system.c,
Sergey Poznyakoff <=
- Re: [Bug-tar] [PATCH] tar: simplify code in system.c, Pavel Raiskup, 2013/02/20