toStringz note about keeping references
Jonathan M Davis
jmdavisProg at gmx.com
Sun Oct 14 17:35:23 PDT 2012
On Monday, October 15, 2012 02:04:44 Andrej Mitrovic wrote:
> On 10/15/12, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> > snip
>
> Hmm ok, this sheds some light on things.
>
> If a C function takes a const pointer and has no documentation about
> ownership then maybe it's a good guess to say it won't store that
> pointer anywhere and will only use it as a temporary?
Generally speaking yes. It's rare for them to keep pointers around, and if
they do and don't tell you, then they're creating bugs in C code too. Most C
functions (especially if you're talking OS functions) which keep memory that
you pass to them or give you memory thaty you didn't pass to them will inform
you about it in their documentation.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list