Nowadays your compiler should do all the work for you. At least of what I know gcc is very efficient in optimizing calls to memset
away (better check the assembler, though).
Then also, avoid memset
if you don't have to:
... = { 0
}
) for stack memoryAnd for really large chunks use mmap
if you have it. This just gets zero initialized memory from the system "for free".