tag:blogger.com,1999:blog-772164822749879307.post6546631791284582249..comments2018-09-01T15:13:50.111+02:00Comments on stanleyxu's area51: Potential memory leaks by initializing a recordstanleyxu (2nd)http://www.blogger.com/profile/12291786770395325696noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-772164822749879307.post-35946811396543838842015-07-21T08:18:12.354+02:002015-07-21T08:18:12.354+02:00You can just use Rec := Default(TRec); and no hack...You can just use Rec := Default(TRec); and no hacks..Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-772164822749879307.post-67223340632565539452009-06-02T11:50:48.299+02:002009-06-02T11:50:48.299+02:00Thanks - a useful article indeed.
I'm busy implem...Thanks - a useful article indeed. <br />I'm busy implementing your articles solution.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-772164822749879307.post-28871343208305732852008-03-24T12:46:00.000+01:002008-03-24T12:46:00.000+01:00In other words the idea is not initializing the st...In other words the idea is not initializing the string but initializing Pointers to Nil and such integers to Zero in the record. An ansistring field is really just a smart pointer.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-772164822749879307.post-74737681171728044082008-03-24T12:42:00.000+01:002008-03-24T12:42:00.000+01:00See also Jonas comment:http://www.mail-archive.com...See also Jonas comment:<BR/><BR/>http://www.mail-archive.com/fpc-pascal@lists.freepascal.org/msg12217.htmlAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-772164822749879307.post-13508609479402733862008-03-24T12:40:00.000+01:002008-03-24T12:40:00.000+01:00See also:http://www.mail-archive.com/fpc-pascal@li...See also:<BR/><BR/>http://www.mail-archive.com/fpc-pascal@lists.freepascal.org/msg12214.html<BR/>http://www.mail-archive.com/fpc-pascal@lists.freepascal.org/msg12211.html<BR/><BR/>Anonymous: because initializing the string with empty '' is tedious when you have to iterate through 10 record fields or 300 record fields... we/he are/is trying to find out ways to initialize a record without tediously going through each record field. An ansistring will stop on the first encounter of #0 if you cast to a pchar and such things when passing into functions that deal with pchars such as winapi.. but a ansistring can hold null values you are right about.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-772164822749879307.post-50913286619187277692008-03-24T11:59:00.000+01:002008-03-24T11:59:00.000+01:00Why do you use FillChar on AnsiString ?! you shoul...Why do you use FillChar on AnsiString ?! you should use empty string instead.<BR/><BR/>using #0 on ansi string is not the right way either, it's not a null terminated string, however most string functions will stop on the first encounter of #0Anonymousnoreply@blogger.com