Checking that a memory area is empty
Mike Frysinger
vapier@gentoo.org
Mon Feb 18 20:06:00 GMT 2013
On Wednesday 06 February 2013 09:54:09 Rich Felker wrote:
> On Wed, Feb 06, 2013 at 09:11:19AM +0100, Shérab wrote:
> > It seems there is no function in the glibc at the moment to check
> > whether a memory area is empty (contains onlyzeros).
> >
> > If this is correct, would it be possible to add such a function?
>
> Slightly off-topic, but if your program needs such a function, it
> could easily be implemented in terms of a loop performing memcmp on a
> fixed-max-size subrange against a static const zero buffer of the
> particular size.
that might be a bit faster, but it sounds like memspn()/memcspn() funcs would
work too. googling for those func names turns up quite a number of existing
implementations.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20130218/11f8d62a/attachment.sig>
More information about the Libc-alpha
mailing list