[OPEN-ILS-DEV] PATCH: srfsh.c (more on shelling out)
Mike Rylander
mrylander at gmail.com
Thu Jul 12 23:59:59 EDT 2007
On 7/12/07, Scott McKellar <mck9 at swbell.net> wrote:
> This patch contains one minor change and one less minor change.
>
[snip less minor change]
>
> The minor change is that, after building an array of pointers
> pointing to tokens from the input command, I set the next
> pointer to NULL so that it mark the end of the token list.
>
> For most systems most of the time, this change will make no
> difference, because a preceding memset() writes a bunch of binary
> zeros to the pointer array. However not all systems represent
> NULL as all-bits-zero.
>
> There is a further subtlety: the memset() doesn't fill the entire
> array. It fills a number of bytes equal to the number of pointers
> in the array. However a pointer occupies more than one byte (with
> rare exceptions). The result is that, on a system with four-byte
> pointers, only one fourth of the pointers get nullified.
This is, in fact, the problem. I've fixed it by using calloc()/free()
instead of using an array. calloc() has the extra benefit of zeroing
the memory, so the first memset() is no longer needed. I left the
NULLification of the last + 1 pointer in place for systems where NULL
!= all-0-bits.
Thanks again, Scott!
--miker
More information about the Open-ils-dev
mailing list