Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Size zero allocations



In the last episode (Mar 06), Bart Schaefer said:
> Press kill-whole-line at an empty prompt, and ElectricFence reports:
> 
> zagzig% ^U
> ElectricFence Aborting: Allocating 0 bytes, probably a bug.
> 
> Is this, in fact, a bug?

Probably.  The Single Unix specs read:

    If the size of the space requested is 0, the behaviour is
    implementation-dependent; the value returned will be either a null
    pointer or a unique pointer.

FreeBSD's malloc can be configured to return either (it defaults to
returning a pointer to a 0-byte malloc structure), and comments:

    It can be argued that returning a null pointer when asked to
    allocate zero bytes is a silly response to a silly question.

Tru64 returns NULL, and Solaris 8's manpage seems to imply that it
returns a pointer.

-- 
	Dan Nelson
	dnelson@xxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author