TOMJ@csdserver3.csd.scarolina.edu (Thomas E. Jenkins, Jr.) (05/18/91)
Hi, I just finished ( kind of ) testing a new Doublely-linked list Object. One of the element objects I made to test it was a String object. The string object's CONSTRUCTOR uses GetMem to allocate memory and the DESTRUCTOR uses FreeMem to de-allocate that memory. For my stack and queue objects, this was fine, but with the DList object, I decided to allow the elements to be altered. The VIRTUAL method SetData for the string deallocated the memory with FreeMem and reallocated memory for the new string. All this worked fine in testing, but now, when I call dispose with the Done DESTRUCTOR, I get a runtime error 208 : Invalid pointer operation. I displayed the size of the string to ensure I wasn't trying to release too much memory, but it was right! My work around was to create a procedure to deallocate the memory and a function to allocate and initiallize the memory and return a pointer to it. This worked fine. My question is : Why? I'd seen in the TV stuff that Borland used NewStr and DisposeStr ( ? ), but thought that was for show. Why is it required? I'll gladly post the code if anyone wants to see. tom +--------------------------------------------------------------------------+ | Thomas E. Jenkins, Jr. Programmer, University of South Carolina CSD | +--------------------------------------------------------------------------+ | BITNET : C0361@UNIVSCVM.BITNET | CSDNET : tomj/csdserver3 | | INTERNET : TOMJ@csdserver3.csd.scarolina.EDU {PREFERRED} | | : C0361@univscvm.csd.scarolina.EDU | 129.252.43.30 | | FROM Compuserv : INTERNET:TOMJ@csdserver3.csd.scarolina.EDU {PREFERRED} | | : INTERNET:C0361@univscvm.csd.scarolina.EDU | +--------------------------------------------------------------------------+