[PATCH] Re: What not to be doing - syscall()

Frans Englich frans.englich at telia.com
Thu Dec 25 09:53:28 GMT 2003

On Wednesday 24 December 2003 19:47, Oswald Buddenhagen wrote:
> On Wed, Dec 24, 2003 at 06:59:35PM +0100, Frans Englich wrote:
> > Ok, second try. This time no dangling pointer,
> ... but a memory leak. ;)

True.. :|

> {
>   KUser ku;
>   pty->login( ku.loginName().latin1(), getenv("DISPLAY"));
> }

Let me see if I got this straight.. Does that code snippet work as good as 
pty->login( KUser().loginName().latin1(), getenv("DISPLAY"));? Is it only a 
more compact way of writing or does it differ in any other way? In case it 
is, would the compiler had optimized the two-statement-solution into 
something identical to the compact?

Regarding Thiago's comment on the code snippet:
+  const char *user = KUser().loginName().latin1();
pty->login( user ... ;
Isn't the "temporary" KUser object created on stack and should live until end 
of scope?


More information about the kde-core-devel mailing list