>"JITHU" <[EMAIL PROTECTED]> a écrit dans le message de news:
>[EMAIL PROTECTED]
>HI all,
>II am presntly trying to develop a application in which the user enters a
>data that need to be saved in a pdb.The problem here is the data length is
>of variable length and in many cases it may be around 100 chars and in some
>cases it may go to 1000 chars also.
>and a deceleration as such like this is required
>Struct xyz
>{
>char *abc;
>}
>
>instead of
>char abc[1000];
>to be stored in the database
>in the pointer case if i allocate a space using memhandle and store the
>data,the data is stored in the pdb ,but once i try to go out of my
>application there is a memory leak..on the other hand if i free the handle
>before logging out of my application ,when i try to access the information
>the next time, i find some junk data being present.
>Please provide some work around for this problem.
>--
>Regards,
>Jithendra Kurasala,
>Software Developer.
>IDEAVATE SOLUTIONS with us think its Done.
>www.ideavate.com
Jithendra,
Here is how to do it.
Note that there is no error checking.
Its just some partial copy and paste to point you in the right dirrection.
Lets day you have Char strText[1000];
You can save only the used part in your record like this.
To allocate the record you do some thing like this:
memhRecordChunk =
DmNewHandle(dbrOpenDbRef,(StrLen(strText)+1)*sizeof(Char));
Then you attach it.
If you have "123" in strText it will create a record of 4 bytes (plus the
hiden header)
To read it back you use some thing like this:
MemSet(strText,1000,0);
memhRecordChunk = DmQueryRecord(dbrOpenDbRef, uintIndex);
strpTmpText= (Char*)MemHandleLock(memhRecordChunk);
MemMove(strText,strpTmpText,MemHandleSize(memhRecordChunk));
MemHandleUnlock(memhRecordChunk);
Hope this helps you.
--
Regis St-Gelais
www.laubrass.com
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/