|
"Smith, Nelson" wrote: > > In my debugging, I've eliminated all references to the pointer except on the > alloc and dealloc statements, so it must be something else I am doing to > other variables that have an effect on it. > > The only oddity I notice (and it may just be a quirk of debug) is that the > data structure contains an array of 400 elements, 46 bytes each, and no > matter if I allocate 46 bytes to the pointer or 46*400, I see the entire 400 > elements when I do F11 on the ds name. I'm trying to only use the amount of > memory needed rather than the maximum 400 array elements. Does Strdbg show > all 400 even if you did not allocate that many? When I only allocate enough > memory for one array element, some of the area debug is showing me past that > first element is getting into a second ds that is allocated and reallocated. > Could this cause some corruption to the first pointer? Is that what you > mean by "touching" the pointer? Is there any way to see the tag bit in > debug? > Nelson, the pointer you get points somewhere within some huge heap of storage. You physically actually have access to everything in the heap following your storage. The debugger doesn't know how much you allocated, so it shows everything it physically can. (Try eval arr(1..40) to limit the number of elements shown by the debugger.) If the pointer itself has been corrupted, the debugger will display it as SPP:*NULL. The only thing I can think of is that you have reallocated the DS but that you still have access to the original allocated pointer. That original pointer will still be pointing into valid storage in the heap, but it won't actually be allocated to you any more. p = %alloc(100); p2 = realloc(p : 200); After the realloc, trying to deallocate or reallocate p will result in an error. But p will still look good, and although any reference to the storage pointed to by p is illegal, you will not get an error for doing it. At least you won't get an error right away, but bad things could happen eventually if the original p storage gets allocated somewhere else.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.