Thanks! I'll check out the first suggestion, but as I never get past the DmNewRecord
statement, the other's don't apply (yet! <g>).
Randy
-----Original Message-----
From: Chris Antos <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Sunday, March 21, 1999 10:29 PM
Subject: Re: DmNewRecord writes to Low mem?
a couple suggestions...
>RecSize = MostoftheStruc + NoteLength;
perhaps this should be "MostoftheStruc + NoteLength + 1" to account for a
null terminator?
> //write out the two parts
> DmWrite (FOTptr,0,&WorkingFieldObs,MostoftheStruc);
this line of code can appear correct but not work correctly if
WorkingFieldObs is not of the same type as MostoftheStruc is expecting. i
personally use the following kind of code (this is a sample off the top of
my head, so i'm not bothering with much error checking):
// MyData holds the constant-size portion of the record
struct tagMyData {
// blah blah
};
typedef struct tagMyData MyData;
...
...
void Foo(CharPtr pszNote)
{
UInt cchNote; // count of chars in note
UInt cbRecord; // count of bytes in record
VoidHand hRec;
VoidPtr pRec;
MyData md;
Assert(pszNote);
// blah blah, whatever
cchNote = StrLen(pszNote);
// notice, if i change the type of md, the size calculation
// automatically compensates, and i'm not using any
// macros, so no confusion; code is easy to read
cbRecord = sizeof(md) + cchNote + 1;
hRec = DmNewRecord(pdb, 0, cbRecord);
pRec = MemHandleLock(hRec);
DmWrite(pRec, 0, &md, sizeof(md));
// you left this out of your example, although the comments
// indicated it should be there -- you aren't missing this in
// your actual code, are you?
DmStrCopy(pRec, sizeof(md), pszNote, cchNote + 1);
// ... blah blah blah
the sample can't be understood without some additional files and
definitions. at the moment, you know those definitions off the top of your
head. but the same thing happens if you put down the project for a couple
months and come back to it. total confusion b/c there are unnecessary
#defines that obfuscate things. if you can make the compiler figure it out,
then generally it's best to make the compiler do the work. it generally
makes the code more robust, as well as easier to understand.
all that said, i have no idea if this is part of the cause of the problem
you're having or not. as Keith said, there's a lot missing from the sample,
and it cannot be parsed to get even an idea of what's happening.