Ok, thanks. So like this:

Boolean cleanUp = false;

tempData = Malloc(4096);

if (!tempData) {
 cacheError(fileErrMemError);
 return 2;
}

for (copied = 0; copied < size; copied += numBytesWrittenP) {

  MemSet(tempData, 4096, 0);

  readBytes = FileRead( cache, tempData, 4096, 1, &fileError);
  if (fileError != errNone) {
   cacheError(fileError);
   cleanUp = true;
   return 2;
  }

  err = VFSFileWrite(fileRefP, readBytes, tempData, &numBytesWrittenP);
  if (err != errNone) {
   VfsError(err);
   cleanUp = true;
   return 2;
  }

 }

Free(tempData);
tempData = NULL;
if (cleanUp = true) return 2;

Also, any reason why the code would only write 200-400 bytes and lock-up?
Could it be the malloc/free calls inside the loop?

Thanks again,
Donald



"Henk Jonas" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Do not malloc and free the block inside the loop. Do it outside, break
> in the case of error to free the memory again.
>
> --
> -------------------------------------------------------------------------
>    Henk Jonas                                            [EMAIL PROTECTED]
>    Palm OS ® certified developer
>
>    Please contact me, if you need an off-site contract worker.
> -------------------------------------------------------------------------
>



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

Reply via email to