X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/sod/blobdiff_plain/a142609c5dc2a7c3df02497235881beaf47088bf..7b7947024fedb0bb7a0ea3ccb0029f6060de901b:/lib/sod.c diff --git a/lib/sod.c b/lib/sod.c index aee28d5..a21a599 100644 --- a/lib/sod.c +++ b/lib/sod.c @@ -159,4 +159,32 @@ void *sod_initv(const SodClass *cls, void *p, va_list ap) return (p); } +/* --- @sod_teardown@ --- * + * + * Arguments: @void *p@ = pointer to an instance to be torn down + * + * Returns: Zero if the object is torn down; nonzero if it refused for + * some reason. + * + * Use: Invokes the instance's `teardown' method to release any held + * resources. + * + * If this function returns nonzero, then the object is still + * active, and may still hold important resources. This is not + * intended to be a failure condition: failures in teardown are + * usually unrecoverable (or very hard to recover from) and + * should probably cause the program to abort. A refusal, on + * the other hand, means that the object is still live and + * shouldn't be deallocated, but that this is a normal situation + * and the caller shouldn't worry about it. + */ + +int sod_teardown(void *p) +{ + SodObject *obj; + + obj = SOD_CONVERT(SodObject, p); + return (SodObject_teardown(obj)); +} + /*----- That's all, folks -------------------------------------------------*/