Re: [Dev-C++] Struckts and pointer .......
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <Met...@ao...> - 2002-08-29 16:52:44
|
mu...@gm... wrote :
> In what you do here, you're overwriting the pointer to the memory allocated,
> causing a memory leak.
Yes indeed !
In fact, I was thinking of one of my program I am currently developping. It
makes intensive use of chained lists like this :
typedef struct _coldesc
{
SQLCHAR ColumnName[255];
SQLSMALLINT NameLength;
SQLSMALLINT DataType;
SQLUINTEGER ColumnSize;
SQLSMALLINT DecimalDigits;
SQLSMALLINT Nullable;
TCHAR *buffer;
SQLLEN IndPtr;
struct _coldesc *next;
};
_coldesc *thisbinding=NULL;
_coldesc *firstbinding=NULL;
_coldesc *nextbinding=NULL;
firstbinding=(_coldesc*)malloc(sizeof(_coldesc));
thisbinding=firstbinding;
**Do calls to SQLDescribeCol here**
nextbinding=(_coldesc*)malloc(sizeof(_coldesc));
thisbinding->next=nextbinding;
thisbinding=thisbinding->next;
Sorry for the misunderstanding ! This small code example shows better what I
was trying to tell.
--
Seb
|