Hi,
I missed the original post, but he Niel's code is wrong,
it should read
CharPtr name = static_cast<CharPtr>(MemPtrNew(StrLen(in_Name)+1));
You MUST remember that the strings are null terminated so allocate
an extra byte for the null, otherwise you will get all sorts of
memory problems.
This is a real C/C++ gotcha!
Paul Todd
-----Original Message-----
From: Danko Radic [mailto:[EMAIL PROTECTED]]
Sent: 03 March 1999 10:22
To: Neil Davidson
Cc: [EMAIL PROTECTED]
Subject: Re: More memory problems.....
I didn't follow the problem from the beginning, but I noticed other
problems with string copying. I.e. StrNCopy(CharPtr dst, CharPtr src,
Word
len) (I'm not sure about last 'Word' - I don't have the manual here, but
it would work!) wouldn't work properly unless you declare:
Char dst[]=" "; //leave enough space
CharPtr src;
...
tmp=StrNCopy(dst,src,StrLen(src));
So, when I declare 'CharPtr dst', it doesn't work!
I'm not sure what the real nature of your problem is, but hope this
would
help!
Danko Radic
On Tue, 2 Mar 1999, Neil Davidson wrote:
> Hi again,
>
> I'm sorry to still be asking about this but I am at the end of my
tether.
>
> I have tried to change the variables of the class to be dynamically
> allocated but this wont work, the code I tried was :
>
> CharPtr name;
> ....
> name = (CharPtr)MemPtrNew(StrLen{in_name));
> StrCpy(name, in_name);
>
> Any ideas why that doesn't work?
>
> I have also changed the array declaration from :
>
> Film filmArray[Max_Film_Num];
>
> to :
>
> Film * filmArray = new Film[Max_Film_Num];
>
> The app still crashes when Max_Film_Num is any greater that 13.
>
> Is there ANYTHING I can do to increase the size of this data
structure? I
> have had a look at some DB code and it makes no sense to me, it really
is
> a last resort.
>
>
> Thanks again for listening,
>
> Neil
>
>
>