Test if memory pointer is valid?



Is there a way or technique for knowing if a pointer points to memory that
has been freed ?

The example is a little silly, in reality, P & Q might fields in instances
of disparate classes

P: Pointer;
Q: Pointer;
BuffSize: Integer;

BuffSize := 32000;
GetMem(P, BuffSize);
F.Read(P^,BuffSize);
....
Q := P;
....
if ...
FreeMem(P,BuffSize)
....

if [ Q points to memory that has not been freed ] // what technique, if
any, can test this?
FreeMem (Q,BuffSize);

end;

--
Richard A. DeVenezia


.



Relevant Pages

  • Re: Is this math test too easy?
    ... > communications glitch; one of the more laughable cartoons ... it was loaded into physical memory and, ... > Or one can interpret the character string as one of the values ... A pointer to an integer? ...
    (sci.math)
  • Re: grow list by tail, pointer example recipe -- please comment
    ... manufacturing a pointer with that address. ... the next cons cell. ... believe these lists are in consecutive memory locations. ...
    (comp.lang.lisp)
  • Re: some unanswered questions on C
    ... A pointer variable that's never been given a value. ... you don't know what memory you're modifying. ... >what i want to ask is that when i declare my buffer for fgets as ... "char *buffer" creates a pointer, ...
    (comp.unix.programmer)
  • Re: "Mastering C Pointers"....
    ... all means go ahead and dive right into the C language. ... Memory is a separate unit which just stores bits. ... A pointer at the hardware level _is an integer_. ... since loops make your logic more much ...
    (comp.lang.c)
  • Re: what is the purpose of C++ smart pointer
    ... pointer tracks the data it is referring to and updates itself ... following the changes of the memory it points to. ... How exactly will the smart pointer know that you moved the ... int * x = new int; ...
    (comp.os.linux.development.apps)