Linux, programming, computers and life

February 11, 2007

do not overuse memset

Filed under: programming, c++

Just a reminder. C++ is not C. memset is a useful function (you know, take-memory-location-and-length-and-fill-it-with-char). But there’s no reason whatsoever to use it in order to reset an object. Define a Reset() method (or choose your own name) and use it.
I’m not just saying it. It’s coming from a frustrated person after looking for a memory bug for day and a half. The bug was memset which reset some variable which was used in other memset and reset a lot of memory this way.
Two lessons learned:

  1. memset is for buffers, not for objects
  2. electric fence is really helpful

Technorati Tags: , , , ,

Comments »

The URI to TrackBack this entry is: http://linux4all.blogsome.com/2007/02/11/do-not-overuse-memset/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.

Get free blog up and running in minutes with Blogsome
Theme designed by Gary Rogers