Regarding free function

H

Hallvard B Furuseth

Vijay said:
ok. Is there any way to return released memory back to OS explicitly?

There could be on your OS, but most likely if you want to return it to
the OS, you must get it from the OS and not from memory "owned" by C.
E.g. mmap() - munmap() on POSIX. For other OSes, I don't know.
 
K

Keith Thompson

Flash Gordon said:
Actually, the standard does not define padding bits for a pointer,
only for integer types.
Right.

So I believe that all bits in the pointer are
part of the representation and therefore unless you call free on that
pointer (which could make the representation become a trap) I believe
using an unsigned char pointer to save the representation to a file
and later reading it back and using it would be perfectly
legal.

Right, but there could still be bits within the representation that
aren't relevant to the value. Two pointer objects with different
representations could compare equal. (This doesn't contradict
anything you've said.)
 
S

Stephen Sprunk

Vijay said:
ok. Is there any way to return released memory back to OS explicitly?

There is no portable way to do that other than terminating your program; in
fact, there may be no "OS" at all, depending on the implementation. Once
you start looking for details beyond the malloc()/free() interface, the
answer is going to be dependent on the particular system being examined.

"If you want to know about your system, ask in a group dedicated to your
system."

S
 
J

Jordan Abel

Eric, ISTR that the NULL pointer was treated differently.
Notwithstanding your comment about font changes as information and text
as carrier, on my old DS9000, the NULL pointer has a "%p" printed
representation of

"You are in a maze of twisty little passages, all alike."

;-)

Are you sure you guys are talking about the DS9000, and not, say, the
AS400?
 

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
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top