justin, I am not sure about this, but at a first glance, I believe that you
are asigning some text into an unallocated chunk of memory, which in
english, means that you are assigning some characters to an address that is
NULL or it is used for another purpose. What you have to do is to assign a
valid address to the char * name, this can be MemPtrNew or either assigning
the address of a char test[10]
I hope this can help you.

-----Mensaje original-----
De: Justin Felker <[EMAIL PROTECTED]>
Para: Palm Developer Forum <[EMAIL PROTECTED]>
Fecha: Lunes, 02 de Abril de 2001 12:09 a.m.
Asunto: Data Storage Troubles


>Please bear with me while I attempt to explain my problem.  I am having a
>bit of trouble from a conceptual angle with saving and retrieving data.  So
>you all know, I have looked through the source of the ROM applications and
>have searched the knowledge base and list archive.  Many sources address my
>question but there is always some small part missing, so please take a look
>and let me know what your thoughts are.
>
>I begin with a structure of Char* that relate to different fields on a form
>(Name, Address, Phone Num, etc).
>
>typedef struct {
> Char* Name;
> Char* Address;
> Char* Company;
>  ...
>} MeetingType;
>
>Now, to fill this structure with the relevant data, I have a save routine
>that is registered as a callback function for a table.  This save routine
>gets a handle to the current field, locks this handle and assigns the
>returned pointer to the members of the structure.
>
> field = TblGetCurrentField(table);
> fieldH = FldGetTextHandle(field);
> ...
> cRecord.Name = MemHandleLock(fieldH);
>
>This is where it gets a bit fuzzy for me.  I can't unlock that handle
>because the pointer I just assigned to cRecord.Name may become invalid if
>the OS decides to change it.  But I don't think I should leave it locked
>either.  Also, this can't be the correct way to do this because after I
save
>this to the database by passing the structure to DmWrite and restart the
>application, the address that I assigned to cRecord.Name shouldn't be valid
>anymore as dynamic memory will have been reset.  As evidence of this, the
>above code works while the application is running but the moment I exit the
>application and restart it I receive errors when trying to reference
>cRecord->Name (The error is: "Meeting" 1.0 has just read directly from an
>unallocated chunk of memory).
>
>I guess my question comes down to what datatype should use in my structure?
>Should I use pointers at all for the data I store using the data manager?
>If not, what do I use?  If so, how exactly does that work?  One only has
>direct access to dynamic memory which will be invalid after an application
>exits.
>
>I would greatly appreciate some direction here.  Thank you in advance.
>
>Justin Felker
>[EMAIL PROTECTED]
>
>
>--
>For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/tech/support/forums/


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

Reply via email to