Just to clarify what Jeremy is saying:  the i++ produces a side effect.  For
example, when i == 1, then execution of the statement x[i++] = y[i++] sets
x[1] == y[2], and i ==3; or x[2] == y[1], and i ==3; depending on which side
of the equation the compiler executes i++ first.  Your best bet is: x[i] =
y[i]; i++;.

Al
----- Original Message ----- 
From: "Jeremy Neal Kelly" <[EMAIL PROTECTED]>
Newsgroups: palm-dev-forum
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Friday, August 22, 2003 11:41 AM
Subject: Re: new/delete problem in PALM OS


> "Alucard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> >
> >     Just like to ask who has encountered this new/delete problem in PALM
> > OS? i tried to implement one using the codewarrior..  with this given
> > value : Char* y = "<b>abc</b> n.\n";
> > wherein i first allocate a storage
> >     e.g. Char* x = new Char[256];
> >            int i = 0;
> > then started storing characters
> >     e.g. x[i++] = y[i++];
> >
> > during this storing characters i've encountered garbages also being
stored
> >
> > then lastly i deallocated
> >     e.g. delete[] x;
> > during deallocation also, it does not free the allocated memory wherein
> > in fact this call is within a function call.
>
> Hmmm... You're copying like this, right?
>
>   x[i++] = y[i++]
>
> Are you seeing 'garbage' at every other character? How many times per copy
> are you incrementing that index counter?
>
> I don't really understand what you wrote about the deallocation problem,
but
> let me ask: how do you know it's not being deallocated?
>
> Jeremy Neal Kelly
> Software Engineer
> Peapod
>
>
>
>
> -- 
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/
>



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to