Thursday, April 23, 2009

Potential memory leaks by initializing a record (revised)

Currently I am involved in some D projects. Language D has nothing to do with Delphi. It has a lot of great features: Design by Contract, Templates, immutable, Array-Slicing, etc. My teammates give me a lot of advices on software design. One thing just inspired me. so I revised my old article "Potential memory leaks by initializing a record".

The main point is that FillChar() looks more like an abuse of initializing a record. I suggest declare a const record (eg. EmptyRecord) instead of using FillChar(). If you are an expert, you will NOT make such a mistake, but it is still worth to tell the rest Delphi developers.
 

No comments: