🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2125

Behaviour of mem functions when n=0 ?

#2125
From: Chris Wilkins
Date: Fri, 01 Mar 1996 15:32
28 lines
1042 bytes
I was wondering if someone could tell me exactly what behaviour is guaranteed 
for the mem library functions when n=0. I presume the answers are:

memcpy()  -> do nothing
memmove() -> do nothing
memset()  -> do nothing
memcmp()  -> return 0
memchr()  -> return NULL

But are these guaranteed?

Also, when n=0 is it guaranteed that these functions will not dereference 
their other arguments? 

Basically, I'm interested whether I can safely use something like:

memcpy(ptr,NULL,0);

or whether I have to wrap it:

if(len>0) {
    memcpy(dest,src,len);
}

Thanks,

Chris 
Technical Details
Message-ID: <4h75af$4ln@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: chrisw@leland.stanford.edu (Chris Wilkins)
Newsgroups: comp.lang.c.moderated
Subject: Behaviour of mem functions when n=0 ?
Date: 1 Mar 1996 09:32:31 -0600
Organization: Stanford University
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4h75af$4ln@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com
X-Newsreader: Trumpet for Windows [Version 1.0 Rev A]