*
* Use: Finds an instance's base address given a pointer to one of
* its ichains, if you know precisely the instance's class and
- * which chain you're pointing to. If you don't, then (a)
- *
- * @(char *)(p) - (p)->_vt->_base@
- *
- * will do the job just fine, and (b) you'll have the wrong
+ * which chain you're pointing to. If you don't, then (a) you
+ * want @SOD_INSTBASE@ below, and (b) you'll have the wrong
* ilayout anyway.
*
* This macro is not intended to be used directly outside of
((struct cls##__ilayout *) \
((char *)(p) - offsetof(struct cls##__ilayout, chead)))
+/* --- @SOD_INSTBASE@ --- *
+ *
+ * Arguments: @p@ = pointer to an instance (i.e., the address of one of its
+ * instance chains)
+ *
+ * Returns: The base address of @p@'s instance layout.
+ *
+ * Use: Finds the base address of an instance. If you know the
+ * dynamic class of the object then @SOD_ILAYOUT@ is faster. If
+ * you don't, this is the right macro, but your options for
+ * doing something sensible with the result are limited, mostly
+ * to simple memory management operations such as freeing or
+ * zeroizing the instance structure.
+ */
+
+#define SOD_INSTBASE(p) ((void *)((char *)(p) - (p)->_vt->_base))
+
/*----- Utility macros ----------------------------------------------------*/
/* --- @SOD_CLASSOF@ --- *