Connecting Tech Pros Worldwide Forums | Help | Site Map

delete problem

GG
Guest
 
Posts: n/a
#1: Jul 23 '05
Hello.

I have structure :

typedef struct SBlog {
long id_blog;

char bl_name[64];

char bl_domain[64];

} SBLOG, *PBLOG;

I made table:

BLOG pBlog = new SBlog[10]

When I try free memory :

delete [] pBlog

I get error :

Debug Assertion Failed !!!.

What I do wrong ???

Thanks for your help

GG













Larry Brasfield
Guest
 
Posts: n/a
#2: Jul 23 '05

re: delete problem


"GG" <Gs@df.pl> wrote in message
news:d1646i$666$1@nemesis.news.tpi.pl...[color=blue]
> Hello.[/color]
Hi.[color=blue]
> I have structure :
>
> typedef struct SBlog {
> long id_blog;
>
> char bl_name[64];
>
> char bl_domain[64];
>
> } SBLOG, *PBLOG;
>
> I made table:
>
> BLOG pBlog = new SBlog[10]
>
> When I try free memory :
>
> delete [] pBlog
>
> I get error :
>
> Debug Assertion Failed !!!.
>
> What I do wrong ???[/color]


Something other than what you have shown.
Most likely, some errant code has altered
the data structures used by the heap manager
such that they no longer conform to its design.
Maybe you overwrote past the end of one or
more of the arrays in your table.

--
--Larry Brasfield
email: donotspam_larry_brasfield@hotmail.com
Above views may belong only to me.


Niels Dybdahl
Guest
 
Posts: n/a
#3: Jul 23 '05

re: delete problem


> typedef struct SBlog {[color=blue]
> long id_blog;
>
> char bl_name[64];
>
> char bl_domain[64];
>
> } SBLOG, *PBLOG;
>
> I made table:
>
> BLOG pBlog = new SBlog[10]
>
> When I try free memory :
>
> delete [] pBlog
> ...
> What I do wrong ???[/color]

The code you have shown can not compile, so you are actually getting the
error message from some other code. Please show the smallest amount of code
that can compile and produce the problem.

Niels Dybdahl


Howard
Guest
 
Posts: n/a
#4: Jul 23 '05

re: delete problem



"GG" <Gs@df.pl> wrote in message news:d1646i$666$1@nemesis.news.tpi.pl...[color=blue]
> Hello.
>
> I have structure :
>
> typedef struct SBlog {
> long id_blog;
>
> char bl_name[64];
>
> char bl_domain[64];
>
> } SBLOG, *PBLOG;
>[/color]

There's no reason in C++ to use this old C style of definition. You can
simply do it like this:

struct BLOG
{
// members here
};

[color=blue]
> I made table:
>
> BLOG pBlog = new SBlog[10][/color]

What's a "BLOG"? You haven't defined that type anywhere in the code you've
shown. Apparently, it's some kind of pointer, since you're using new with
it.
[color=blue]
>
> When I try free memory :
>
> delete [] pBlog
>
> I get error :
>
> Debug Assertion Failed !!!.
>
> What I do wrong ???[/color]

Something other than what you've shown is wrong, unless BLOG is a valid
pointer type defined elsewhere, and you're using it wrong by assigning it
the results of "new SBlog[10]".

-Howard


Closed Thread