[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

catching deallocation bugs in Smalltalk



MarkM had a great idea for catching premature deletes in smalltalk.

The delete operation can create an object of the class DeletedObject
which has very little protocol (similar to the NULL object).  It then
'becomes' the object to be deleted with the DeletedObject.  The become
operation (blech) swaps the pointers for the two objects:  all
pointers to the first object become pointers to the second, and
vice-versa.  Any manipulation of the DeletedObject will report an
immediate error.  Also, we'll be able to find all instances of
DeletedObject to figure out if we're keeping any pointers!

Cute, huh!?  We should do this before performing major testing in C++.
If anyone gets bored or inspired enough to do this, the NULLClas and
VoidClass represent similar objects.  Actually, the above operation
could just swap the deleted object with a VOID pointer.

dean