memset has the signature
[code]void *memset(void *s, int c, size_t n);[/code]
Anyone know what happens if you call it this way??
[code]memset([size=3][blue]NULL[/blue][/size], , );[/code]
I'm wondering if sees the NULL and then knows not to do anything (like a no-op) or if it will crash/something-else because it's trying to access the NULL... Or is the whole situation just undefined...???
I can't find any documentation or examples that tells what happens in this case... Of course I could write a quick test program, but it would be platform-specific, and I want to know if there is a standard definition of this behaviour... My point is, I have a lot of code to zero out a structure tree with lots of pointers, and I'm hoping there's some way that it will be smart and do a no-op... Otherwise, everywhere I could potentially have a NULL pointer, I'm going to have to go add
memset(ptr, 0, );[/code]
And I really don't want to have to do that...
0 · ·