Browse Source Download (without any required ccan dependencies)

Module:

tal/autoptr

Summary:

automatic updates of pointers to tal objects.

Maintainer:

Rusty Russell <rusty@rustcorp.com.au>

Dependencies:

Description:

This code updates pointers when the pointed-to object is freed.

Example:

#include <ccan/tal/autoptr/autoptr.h>
#include <assert.h>

static void *p;

int main(void)
{
        char *c = tal(NULL, char);

        // Sets p to point to c.
        autonull_set_ptr(NULL, &p, c);
        assert(p == c);

        // Automatically clears p.
        tal_free(c);
        assert(p == NULL);
        return 0;
}

License:

BSD-MIT