Well, there's a few issues here. First of all, what is StaticRecordingInfo?
If the NameString member isn't the correct size, then the StrCopy() will
definitely cause problems... is the NameString member a char* or a
char[SOME_LENGTH]? If it's a char*, you also need to allocate memory to it.
Second of all, you are leaking memory. Since LCurrentStatPtr is a local
var, it is going out of scope at the end of this function and you never
free it.
Not to be harsh, but you have a lot to learn about Memory Management. If I
were you, I'd read up as much as possible about Palm OS memory management,
and Memory management in general. If you don't understand how memory works
in programming, you will have permanent headaches trying to program. I
should know, I had a headache for the first few months I was programming
Palm ;) Being a master at how memory works isn't an option in programming.
It's simply a necessity.
Good luck,
Alan Pinstein
Synergy Solutions, Inc.
http://www.synsolutions.com
1-800-210-5293
>Hi all,
>
>thanks for you plethora of suggestions on my last problem..
>
>I keep getting a bus err with this little chunk of code. . I'm following
>examples in the O'r book.. and Cripes! I can't figure out why. I'm sure
>it has something to do with my complete lack of understanding.. but I
>thought one second from yall would save me hours. :) Thanks..
>
>static Boolean DatabaseOkButtonHook(void)
>{
> StaticRecordingInfo *LCurrentStatPtr;
> FieldPtr fld = GetObjectPtr(databaseNameStringField);
>
> gCurrentStatHand = MemHandleNew(sizeof (StaticRecordingInfo));
> LCurrentStatPtr = MemHandleLock(gCurrentStatHand);
>
> //here we're copying the new database name into memory
> if (FldGetTextPtr(fld) != NULL)
> {
> StrCopy(LCurrentStatPtr->NameString, FldGetTextPtr(fld));
> }
> MemHandleUnlock(gCurrentStatHand);
>
> if ( checkDBName(LCurrentStatPtr->NameString) )
> {
> FrmGotoForm(RecordForm);
> }
> else
> {
> FrmAlert(DbnameAlert);
> }
> return 0;
> }
>
>Any ideas?
>
>Thanks again,
>
>Philip J.