
4 May
2011
4 May
'11
9:27 p.m.
On 4 May 2011 15:14, Stewart, Robert <Robert.Stewart@sig.com> wrote:
g()'s interface returns a reference and not a pointer. That is a clear indication that g()'s caller does not own the memory. By contrast, f() returns a pointer. The caller is not unreasonable in thinking ownership might be transferred, particularly if local conventions indicate as much.
I have a hard time imaging a useable code base which has a convention that any time a pointer is returned one should assume that the memory must be deleted by the caller. You couldn't even call something as simple as strncat in such an environment, let alone most libraries with a C API. -- Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404