B
Britt Hibbert
Hi all
I am working on a 16 bit DOS program, and using Borland to compile my
program.
As a debugging step I have put in the
long coresize = coreleft();
printf("Core left in bytes %ld\n", coresize);
lines of code every time I calloc and free memory. The structs that I
am dynamically allocating and freeing are stored in a linked list, and
I have stepped through the memory freeing code with the TD.exe DOS
debugger. When a node in the linked list is removed, the step through
with the DOS debugger shows me that pointers are being redirected
property etc, and that the pointer passed to free points to the
correct memory location. However, the subsequent call to coreleft does
not report this extra memory after it has been freed.
Subsequent calls to calloc result in different reports from coreleft -
at times after I call calloc, the reported coreleft() value does not
change - I assume this is because the calloc received a pointer to the
memory that was earlier freed but not reported freed by coreleft().
However, at other times, the coreleft value after the calloc IS
smaller, as a result it looks like my program is leaking memory.
However, as I have said, I have stepped through the code with a
debugger numerous times to ensure that pointers were redirected
properly and that the correct pointer was passed to free()
any ideas on what is going on? I am wondering if coreleft is not
reporting the freed memory or if I am doing something wrong.
thanks
Britt Hibbert
I am working on a 16 bit DOS program, and using Borland to compile my
program.
As a debugging step I have put in the
long coresize = coreleft();
printf("Core left in bytes %ld\n", coresize);
lines of code every time I calloc and free memory. The structs that I
am dynamically allocating and freeing are stored in a linked list, and
I have stepped through the memory freeing code with the TD.exe DOS
debugger. When a node in the linked list is removed, the step through
with the DOS debugger shows me that pointers are being redirected
property etc, and that the pointer passed to free points to the
correct memory location. However, the subsequent call to coreleft does
not report this extra memory after it has been freed.
Subsequent calls to calloc result in different reports from coreleft -
at times after I call calloc, the reported coreleft() value does not
change - I assume this is because the calloc received a pointer to the
memory that was earlier freed but not reported freed by coreleft().
However, at other times, the coreleft value after the calloc IS
smaller, as a result it looks like my program is leaking memory.
However, as I have said, I have stepped through the code with a
debugger numerous times to ensure that pointers were redirected
properly and that the correct pointer was passed to free()
any ideas on what is going on? I am wondering if coreleft is not
reporting the freed memory or if I am doing something wrong.
thanks
Britt Hibbert