BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need help deciphering a CodeGuard error

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
William Charles Nickerson
Guest





PostPosted: Thu Apr 29, 2004 2:16 pm    Post subject: Need help deciphering a CodeGuard error Reply with quote



Hello Everyone.

I have turned on CodeGuard to try and help me solve what appears to be a
memory issue. It seems
to be related to THashedStringList. This is part of the cgl file. This is
repeated each time my code
uses new THashedStringList.

Error 00098. 0x130C10 (Thread 0x06A4):
Method called on illegally casted object: Attempt to access 64 byte(s) at
0x015AA9E0. The 'this' pointer points to heap block 0x015AA9E0 which is
only
60 bytes long.
Call Tree:
0x0023BA06(=FileAXS.bpl:0x01:00AA06) c:program
filesborlandcbuilder6includevclIniFiles.hpp#166
0x0023B94E(=FileAXS.bpl:0x01:00A94E)
C:pttsrcFileAXS2KFileAXSINI.cpp#18
0x0023852E(=FileAXS.bpl:0x01:00752E)
C:pttsrcFileAXS2KFileAXSServer.cpp#890
0x004021E9(=PTTViewer.exe:0x01:0011E9)
C:pttsrcPTT2KPTTImageBar.cpp#24
0x400F59A4(=vcl60.bpl:0x01:0449A4)
0x00401B4E(=PTTViewer.exe:0x01:000B4E) C:pttsrcPTT2KPTTViewer.cpp#15

The memory block (0x015AA9E0) [size: 60 bytes] was allocated with SysGetMem
Call Tree:
0x40002FCF(=rtl60.bpl:0x01:001FCF)
0x0023B94E(=FileAXS.bpl:0x01:00A94E)
C:pttsrcFileAXS2KFileAXSINI.cpp#18
0x0023852E(=FileAXS.bpl:0x01:00752E)
C:pttsrcFileAXS2KFileAXSServer.cpp#890
0x004021E9(=PTTViewer.exe:0x01:0011E9)
C:pttsrcPTT2KPTTImageBar.cpp#24
0x400F59A4(=vcl60.bpl:0x01:0449A4)
0x00401B4E(=PTTViewer.exe:0x01:000B4E) C:pttsrcPTT2KPTTViewer.cpp#15

------------------------------------------
My class (TFileAXSIniFile) is a copy of TMemIniFile (converted to C++)
modified to handing reading the INI file from a stream rather than a file.

I changed all *TStrings and *TStringList in the class to *THashedStringList
to see if this was a problem
but the results were the same.

When CodeGuard stops the program it is in the IniFiles.hpp at the
constructor for the THashedStringList class
(which is an inline method). This is the class:

class DELPHICLASS THashedStringList;
class PASCALIMPLEMENTATION THashedStringList : public Classes::TStringList
{
typedef Classes::TStringList inherited;

private:
TStringHash* FValueHash;
TStringHash* FNameHash;
bool FValueHashValid;
bool FNameHashValid;
void __fastcall UpdateValueHash(void);
void __fastcall UpdateNameHash(void);

protected:
virtual void __fastcall Changed(void);

public:
__fastcall virtual ~THashedStringList(void);
virtual int __fastcall IndexOf(const AnsiString S);
virtual int __fastcall IndexOfName(const AnsiString Name);
public:
#pragma option push -w-inl
/* TObject.Create */ inline __fastcall THashedStringList(void) :
Classes::TStringList() { } <-- This is where debugger stops
#pragma option pop

};

I cannot find any information on what "Method called on illegally casted
object" means. Google brings up
a couple sites, however only 2 are in English and only one has a solution
(which is to turn off
Zero length empty class methods in the C++ options). I will try this but
I'm not sure what affect this will
have or if it is just hiding a deeper issue.

Ciao
Bill


Back to top
JD
Guest





PostPosted: Thu Apr 29, 2004 7:28 pm    Post subject: Re: Need help deciphering a CodeGuard error Reply with quote



"William Charles Nickerson" <bill (AT) wcnickerson (DOT) ca> wrote:
Quote:
[...] This is repeated each time my code uses new THashedStringList.

Try putting the derived class into a seperate unit.
Click File | New | Unit and make the new unit look like:

//---- in the header ------------------------------------------
#ifndef Unit2H
#define Unit2H
//-------------------------------------------------------------
#include <Classes.hpp>
//-------------------------------------------------------------
class THashedStringList : public TStringList
{
protected:
virtual void __fastcall Changed(void);
private:
typedef TStringList inherited;
// you'll need to define what TStringHash is
TStringHash* FValueHash;
TStringHash* FNameHash;
bool FValueHashValid;
bool FNameHashValid;
void __fastcall UpdateValueHash();
void __fastcall UpdateNameHash();
public:
// if you only need to read the values external from the class
__property TStringHash* NameHash = { read = FNameHash };
__property TStringHash* ValueHash = { read = FValueHash };
__property bool NameHashValid = { read = FNameHashValid };
__property bool ValueHashValid = { read = FValueHashValid };
// if you need to set the properties from outside of the class
__property TStringHash* NameHash = { read = FNameHash, write = FNameHash };
__property TStringHash* ValueHash = { read = FValueHash, write = FValueHash };
__property bool NameHashValid = { read = FNameHashValid, write = FNameHashValid };
__property bool ValueHashValid = { read = FValueHashValid, write = FValueHashValid };

// these methods are already public you can remove them
// unless you're overriding them with your own methods
virtual int __fastcall IndexOf(const AnsiString S);
virtual int __fastcall IndexOfName(const AnsiString Name);
// constructor and destructor
__fastcall THashedStringList( void );
__fastcall THashedStringList::~THashedStringList();
};
//-------------------------------------------------------------
#endif


//------ in the unit ------------------------------------------
#pragma hdrstop
#include "Unit2.h"
//-------------------------------------------------------------
#pragma package(smart_init)
//-------------------------------------------------------------
__fastcall THashedStringList::THashedStringList( void ) : TStringList( void )
{
// add any default initialization here
FValueHash = NULL;
FNameHash = NULL;
FNameHashValid = false;
FValueHashValid = false;
}
//-------------------------------------------------------------
__fastcall THashedStringList::~THashedStringList()
{
// the destructor
// free all allocated memory and clean up after yourself
}
//-------------------------------------------------------------
void __fastcall THashedStringList::UpdateValueHash()
{
// add your code here
}
//-------------------------------------------------------------
void __fastcall THashedStringList::UpdateNameHash(void)
{
// add your code here
}
//-------------------------------------------------------------

Now all you have to do is to #include the header in the unit
that allocates the THashedStringList and have at it.

~ JD


Back to top
William Charles Nickerson
Guest





PostPosted: Thu Apr 29, 2004 7:43 pm    Post subject: Re: Need help deciphering a CodeGuard error Reply with quote



Hi JD

I appreciate the help, but my derived class is not the problem -- an
existing VCL class is.

I am not deriving from THashedStringList -- it is already there. I am
deriving from TCustomIniFile and
using TMemIniFile as the model. It uses THashedStringList so I am using it
too.

When I mentioned new THashedStringList I meant something like:

List = new THashedStringList;

I have discovered where my error were occurring and this has absolutely
nothing to do with it although
CodeGuard does complain that 'this' is not valid. However, the constructors
don't appear to use
'this' so it never really causes a problem in the "real world" when the
application runs. CodeGuard
is just being overly cautious from what I can gather.

Aloha
Bill


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.