Donald C. Kirker wrote:
I forgot to mention, the program hangs in this code:

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

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

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

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

  Free(tempData);
  tempData = NULL;
 }


Thanks,
Donald




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