I'm not sure why the compiler is complaining, but your code does seem to be wrong.
if (!h) means if there is no handle, so you definitely don't want to unlock it if it
was null.
Besides... where's the MemHandleLock to match that unlock on that null handle? You
have a couple of layers of problems here...
basically, you want to do:
MemHandle h = DmQueryRecord(dbPtr, index);
if(h)
{
// do your MemHandleLock(h) and the rest of your manipulations
// Then MemHandleUnlock(h) before going on to the next record
}
else
{
return; // or report error, etc.
}
Also, this line is not doing what you seem to intend:
Char *nom = cod + codLen + 1;
What you seem to intend to do is:
Char *nom = MemPtrNew(cod + codLen + 1);
In short, you have several problems to work out here....
Kevin
-----Original Message-----
From: R�gis Daniel de Oliveira [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 15, 2003 3:57 PM
To: Palm Developer Forum
Subject: Wy i,m getting this error?
I have the following code in my app:
void loadRCAS(UInt16 Modo)
{
//Declara variavel Count:
UInt16 Count;
//Configura os ponteiros para a lista
FormPtr form = FrmGetActiveForm();
ListPtr lptr = (ListPtr)FrmGetObjectPtr(form, FrmGetObjectIndex(form,
lstRCAS));
//Verifica se o banco de dados est� aberto. Se nao estiver, abre-o
Err err = Open();
if(err)
return;
else
{
//Faz um LOOP do n�mero de records presente no banco de dados
for (Count=0; DmNumRecords(dbPtr)-1 ; Count++)
{
//Abre o RECORD para leitura
MemHandle h = DmQueryRecord(dbPtr, Count);
//Verifica se eu realmente peguei um bom segmento de memoria
if (!h)
///////////I WANT TO PUT MenHandleUnlock here!!!///////
//MemHandleUnlock(h);
return;
else
{
//Trava o segmento, de modo que eu possa ler dele
Char *cod = (Char *) MemHandleLock(h);
UInt16 codLen = StrLen(cod);
Char *nom = cod + codLen + 1;
//Prepara o ponteiro nome...
Char name[31];
StrNCopy(name, nom, 30);
name[30-1] = 0;
//Acrescenta o item na lista...
DLstCatEntry(listEntries, &nextListEntry,
MAX_LIST_ENTRIES, name);
}
}
}
}
When i put the function MemHandleUnlock(h); before the second 'return', the
compiler generates a error. Why?
Thanks!
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/
------------------------------------------
The information in this transmittal and any attachments is privileged and confidential
and is intended only for the recipient(s) listed above. You are hereby notified that
any unauthorized distribution or copying of this transmittal or its attachments is
prohibited. If you have received this transmittal in error, please notify Invivodata
immediately at (831) 438-9550.
------------------------------------------
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/