X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/a142609c5dc2a7c3df02497235881beaf47088bf..6afec9101d5ea87e3df4bda2239ffd05f8154fa6:/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 -------------------------------------------------*/