delete problem

G

GG

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
 
L

Larry Brasfield

GG said:
Hello. Hi.
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 ???


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.
 
N

Niels Dybdahl

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
...
What I do wrong ???

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
 
H

Howard

GG said:
Hello.

I have structure :

typedef struct SBlog {
long id_blog;

char bl_name[64];

char bl_domain[64];

} SBLOG, *PBLOG;

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
};

I made table:

BLOG pBlog = new SBlog[10]

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.
When I try free memory :

delete [] pBlog

I get error :

Debug Assertion Failed !!!.

What I do wrong ???

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,055
Members
47,659
Latest member
salragu

Latest Threads

Top