4 ms·
memset sets a block of memory to a given value. It is often used to initialize an uninitialized block of memory to 0. So often, in fact, that this bug where it
by justinweiss 16y ago
memset sets a block of memory to a given value. It is often used to initialize an uninitialized block of memory to 0. So often, in fact, that this bug where it always initialized the memory to 0 survived so long.
- mey 16y agoWish there was a cross-link to a bug tracking system where this was initially reported.
- pufuwozu 16y agoYou can just search for the change ID: https://review.source.android.com/#change,14699 https://review.source.android.com/#change,14699
- abstractbill 16y agoSo often, in fact, that this bug where it always initialized the memory to 0 survived so long. Given that the bug went undetected for so long, I think you could almost reasonably claim that calling memset with a nonzero parameter is a "corner case" ;)
- Psyonic 16y agoIt is a "corner case," or close to it, but that's not why it wasn't caught here. I don't think this code is ever called, as explained above. It's default code in case there isn't a platform specific version, but there pretty much always is a platform specific version. Link: http://news.ycombinator.com/item?id=1379639 http://news.ycombinator.com/item?id=1379639
- fserb 16y agoon Google code search: "lang:c memset\(.+,\s[^0]+\s,.+\)" return 32k results and "lang:c memset\(.+,\s0+\s,.+\)" returns 335k.
- wlievens 16y ago10% is a lot more than I would have thought, wow. Good job looking that up.