I guess I didn't frame my question properly.  MemSet is setting my stuct to 
a null value, so that I cannot enter data into the struct.  Here is a code 
snippit.

DB is a struct containing other structs from the ThinkDB .h file.  I've 
commented where the program crashes below.  All function calls are to 
ThinkDB.c file.  This program is for my junior project in college....I'm 
getting pretty desperate on solving this problem.

   Database *DB; //declaring an instance of my struct for use
   DB = MemPtrNew(sizeof(char*) * sizeof(Database));

        /* First create empty database */
        MemSet(&DB->dbInfo, sizeof(DB->dbInfo), 0);
        StrCopy(DB->dbInfo.dbName, "SIR");
        DB->dbInfo.passwords = DB->passwords;

        TdbCreateDB(&DB->dbInfo);

        TdbGetDBInfo(&DB->dbInfo);

/* Set Field 1 to a text field */
MemSet(&DB->fieldPropInfo, sizeof(TdbFieldPropType), 0);
StrCopy(DB->fieldPropInfo.dbName, "SIR");
DB->fieldPropInfo.fieldNum = 1;
DB->fieldPropInfo.passwords = DB->passwords;
DB->fieldPropInfo.fieldProp.name = "Station";
DB->fieldPropInfo.fieldProp.type = tdbFtText;
DB->fieldPropInfo.fieldProp.props.text.defaultStr = "empty"; file://text to 
insert into the field
TdbSetFieldProperties(&DB->fieldPropInfo);

/* Set Field 2 to a text field */
MemSet(&DB->fieldPropInfo, sizeof(TdbFieldPropType), 0);
StrCopy(DB->fieldPropInfo.dbName, "SIR");
DB->fieldPropInfo.fieldNum = 2;

DB->fieldPropInfo.passwords = DB->passwords;
DB->fieldPropInfo.fieldProp.name = "Date";
DB->fieldPropInfo.fieldProp.type = tdbFtText;
DB->fieldPropInfo.fieldProp.props.text.defaultStr = "empty";
TdbSetFieldProperties(&DB->fieldPropInfo);

/* Set Field 3 to a text field */
MemSet(&DB->fieldPropInfo, sizeof(TdbFieldPropType), 0);
StrCopy(DB->fieldPropInfo.dbName, "SIR");
DB->fieldPropInfo.fieldNum = 3;

DB->fieldPropInfo.passwords = DB->passwords;
DB->fieldPropInfo.fieldProp.name = "O2";
DB->fieldPropInfo.fieldProp.type = tdbFtText;
DB->fieldPropInfo.fieldProp.props.text.defaultStr = "empty";
TdbSetFieldProperties(&DB->fieldPropInfo);

/* Set Field 4 to a text field */
MemSet(&DB->fieldPropInfo, sizeof(TdbFieldPropType), 0);
StrCopy(DB->fieldPropInfo.dbName, "SIR");
DB->fieldPropInfo.fieldNum = 4;

DB->fieldPropInfo.passwords = DB->passwords;
DB->fieldPropInfo.fieldProp.name = "Salinity";
DB->fieldPropInfo.fieldProp.type = tdbFtText;
DB->fieldPropInfo.fieldProp.props.text.defaultStr = "empty";
//crahses at the statement below.  My struct has a value of NULL and cannot 
enter data here.
TdbSetFieldProperties(&DB->fieldPropInfo);

/* Set Field 5 to a text field */
MemSet(&DB->fieldPropInfo, sizeof(TdbFieldPropType), 0);
StrCopy(DB->fieldPropInfo.dbName, "SIR");
DB->fieldPropInfo.fieldNum = 5;

DB->fieldPropInfo.passwords = DB->passwords;
DB->fieldPropInfo.fieldProp.name = "Comments";
DB->fieldPropInfo.fieldProp.type = tdbFtText;
DB->fieldPropInfo.fieldProp.props.text.defaultStr = "empty";
TdbSetFieldProperties(&DB->fieldPropInfo);

/* Add the record */
StrCopy(DB->recordInfo.dbName, "SIR");
DB->recordInfo.passwords = DB->passwords;
DB->recordInfo.fieldValues = 0L;
TdbAddRecord(&DB->recordInfo);



>From: Joe Reply-To: "Palm Developer Forum" To: "Palm Developer Forum" 
>Subject: Re: MemSet problem Date: Wed, 1 May 2002 11:48:53 -0700 (PDT)
>
>--- Brett --------- wrote: > I'm using a ThinkDB database to store 
>information and > everytime I try to create the fields for the third > 
>record my MemSet function returns a NULL. > Do I have to free the memory 
>MemSet uses? Am I running > out of heap space? > Any help would be greatly 
>appreciated.
>
>the prototype for MemSet is Err MemSet (void* dstP, Int32 numBytes, UInt8 
>value)
>
>and it *always* returns 0, which == NULL, MOL.
>
>MemSet does not use any memory that you have to free. MemSet sets a memory 
>range in the dynamic heap to a specific value. The memory range starts at 
>the address of 'dstP', and continues for 'numBytes' bytes. It sets all of 
>those bytes to 'value'.
>
>I guess you really are asking about something other than MemSet? Maybe you 
>should show us some code that demonstrates the problem.
>
>
>__________________________________________________ Do You Yahoo!? Yahoo! 
>Health - your guide to health and wellness http://health.yahoo.com
>
>--
>For information on using the Palm Developer Forums, or to unsubscribe, 
>please see http://www.palmos.com/dev/support/forums/


>From: Joe <[EMAIL PROTECTED]>
>Reply-To: "Palm Developer Forum" <[EMAIL PROTECTED]>
>To: "Palm Developer Forum" <[EMAIL PROTECTED]>
>Subject: Re: MemSet problem
>Date: Wed, 1 May 2002 11:48:53 -0700 (PDT)
>
>--- Brett --------- <[EMAIL PROTECTED]> wrote:
> > I'm using a ThinkDB database to store information and
> > everytime I try to create the fields for the third
> > record my MemSet function returns a NULL.
> > Do I have to free the memory MemSet uses?  Am I running
> > out of heap space?
> > Any help would be greatly appreciated.
>
>the prototype for MemSet is
>   Err MemSet (void* dstP, Int32 numBytes, UInt8 value)
>
>and it *always* returns 0, which == NULL, MOL.
>
>MemSet does not use any memory that you have to free.  MemSet sets a
>memory range in the dynamic heap to a specific value.  The memory range
>starts at the address of 'dstP', and continues for 'numBytes' bytes.
>It sets all of those bytes to 'value'.
>
>I guess you really are asking about something other than MemSet?  Maybe
>you should show us some code that demonstrates the problem.
>
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! Health - your guide to health and wellness
>http://health.yahoo.com
>
>--
>For information on using the Palm Developer Forums, or to unsubscribe, 
>please see http://www.palmos.com/dev/support/forums/


_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com


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

Reply via email to