Hacker Newsnew | comments | ask | jobs | submitlogin
sn 538 days ago | link | parent

A good solution in c is to use calloc, which is malloc + zero'ing out the memory.

http://www.cplusplus.com/reference/clibrary/cstdlib/calloc/

Also, in a standards-compliant compiler, statically declared variables are automatically initialized to zero unless stated otherwise.



Someone 538 days ago | link

That won't work here. Here, the goal is to have 'cfree': zero'ing out memory and then freeing it.

-----

sn 538 days ago | link

OK, shows me for skimming too much.

There apparently used to be a cfree though it appears to be equivalent to free.

I upvoted rwg's comment regarding CERT's Secure Coding wiki. memset_s is the correct solution given it is part of the C11 standard.

-----




Lists | RSS | Bookmarklet | Guidelines | FAQ | DMCA | News News | Feature Requests | Bugs | Y Combinator | Apply | Library

Search: