free(): invalid pointer

C

c language

Hi All,

I have written a C++ program, it can be compiled (in UNIX) but when I
run it, I usually gives the following errors:

free(): invalid pointer 0x51d4a0!
free(): invalid pointer 0x51d460!
free(): invalid pointer 0x51d760!
free(): invalid pointer 0x51d7e0!
..
..
..

Can anyone help me to know what is the reason for this problem?

Thanks,
 
I

Ian Collins

c said:
Hi All,

I have written a C++ program,

Then you should go down the hall to the C++ group.
it can be compiled (in UNIX) but when I
run it, I usually gives the following errors:

free(): invalid pointer 0x51d4a0!
free(): invalid pointer 0x51d460!
free(): invalid pointer 0x51d760!
free(): invalid pointer 0x51d7e0!
..
..
..

Can anyone help me to know what is the reason for this problem?
Passing an invalid pointer to free? When you post on the C++ group,
include the code.
 
R

Robert Gamble

c said:
Hi All,

I have written a C++ program, it can be compiled (in UNIX) but when I
run it, I usually gives the following errors:

free(): invalid pointer 0x51d4a0!
free(): invalid pointer 0x51d460!
free(): invalid pointer 0x51d760!
free(): invalid pointer 0x51d7e0!

Can anyone help me to know what is the reason for this problem?

Why don't you try posting your question, along with a small, complete,
compilable example that demonstrates your issue, to comp.lang.c++. It
is very difficult to know exactly what the problem is without seeing
your code although, and I am going out on a limb here, you may be
trying to free an invalid pointer (i.e. a pointer that was not returned
to you by malloc and friends).

Robert Gamble
 
M

Michael Mair

seni.yin said:
make sure the memory your pointer point to is allocated by fuction
"malloc"!

What are you responding to? Please quote sufficient context.
The above may be right or wrong, depending on the context.

Cheers
Michael
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top