[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    Re: kdenonbeta/kopete/protocols/gadu
From:       Zack Rusin <zack () kde ! org>
Date:       2002-09-30 23:50:43
[Download RAW message or body]

On Monday 30 September 2002 19:41, Duncan Mac-Vicar Prett wrote:
> El Monday 30 September 2002 18:45, Zack Rusin escribió:
> > Thanks, but the strings stuff is incorrect.
> > p.password = password.latin1(); was OK,
> > strcpy(p.password, password.latin1()); is not.
> >
> > Zack
>
> why?

strcpy doesn't allocate memory, strdup does. p.password is just a 
pointer and doesnt' have momory for the string allocated to it. latin1() 
returns a const char* pointer valid for as long as the QString is there, 
which in this case is the lifetime of that function, that's all we want, 
we don't want to be unnecessarily copying/allocating memory.

Zack

-- 
Dream as if you'll live forever. 
Live as if you'll die tomorrow. 

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic