Donald, If by "(I think I tried StrLen)" you mean that you tried it in lieu of MemPtrSize, then please try the latter. Calling StrLen is incorrect, since the data you are downloading is in all likelihood not NUL-terminated text. If the data is actually composed of bytes that could include NUL bytes, then you'd be measuring the number of bytes up until -- and not including -- that first NUL. In all cases I can think of, you'd still be creating a buffer that was too small.
The fact that "buf" is a "char*" is probably irrelevant. A char*-type pointer is frequently used to access any kind of data at a byte level, regardless of whether or not that data is actually text characters. For instance, IIRC, your code uses SARbuf to access the first byte of the returned data in order to determine how to process the data. This byte-access is facilitated by declaring SARbuf as a char*. If it were a void* (a type commonly used to reference a block of unformatted data), it would be more difficult to access the first byte. BTW, I wonder about the protocol you're using. For instance, you call recv() to read all bytes that have been received up until that point. However, it's not clear to me how you handle the case of receiving two packets between calls to recv(). Wouldn't both of them be returned by that call to recv()? I don't recall your doing anything to split those two packets apart. -- Keith > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Donald C. Kirker > Sent: Tuesday, December 07, 2004 5:10 PM > To: Palm Developer Forum > Subject: Re: Move memory chunk to another memory chunk > > Err, probably not. I also tried replacing sizeof with > MemPtrSize or StrLen (I think I tried StrLen), but the device > would still crash when calling the last "memcpy(buf, SARbuf, > s); // <= Problem is here." I even tried StrCopy since "buf" > is a char*. > > Thanks, > Donald > > "Keith Rollin" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > > MemPtrResize (buf, sizeof(SARbuf)); > > > memcpy(buf, SARbuf, s); // <= Problem is here > > > > Since SARbuf is a char*, sizeof(SARbuf) is 4, leading to > the size of "buf" > > being 4. Is that what you want? > > > > -- Keith > > > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] > > > [mailto:[EMAIL PROTECTED] On Behalf Of > Donald C. > > > Kirker > > > Sent: Monday, December 06, 2004 5:58 PM > > > To: Palm Developer Forum > > > Subject: Move memory chunk to another memory chunk > > > > > > Here is my problem, When I call the function as shown below, with > > > source, the data is transmitted fine, but once I get all the data > > > into the temporary buffer (SARbuf) after receiving it > into the main > > > buffer (buf) I want to move it back to the main buffer (buf). the > > > problem comes when I call memcpy(buf, SARbuf, s). I > receive a fatal > > > alert with no error information. All the other calls to > memcpy work > > > fine, except thie one. What might I be doing wrong? Also, > memcpy is > > > from the Palm-Unix header file included in the PalmOS 4 SDK's (it > > > just defines it as MemMove). > > > > > > Thanks, > > > Donald > > > > > > > > -- > 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/
