]> git.ozlabs.org Git - ccan/blob - ccan/tal/autoptr/_info
tal/autoptr: new module.
[ccan] / ccan / tal / autoptr / _info
1 #include "config.h"
2 #include <stdio.h>
3 #include <string.h>
4
5 /**
6  * tal/autoptr - automatic updates of pointers to tal objects.
7  *
8  * This code updates pointers when the pointed-to object is freed.
9  *
10  * Maintainer: Rusty Russell <rusty@rustcorp.com.au>
11  * License: BSD-MIT
12  * Example:
13  *      #include <ccan/tal/autoptr/autoptr.h>
14  *      #include <assert.h>
15  *
16  *      static void *p;
17  *
18  *      int main(void)
19  *      {
20  *              char *c = tal(NULL, char);
21  *
22  *              // Sets p to point to c.
23  *              autonull_set_ptr(NULL, &p, c);
24  *              assert(p == c);
25  *
26  *              // Automatically clears p.
27  *              tal_free(c);
28  *              assert(p == NULL);
29  *              return 0;
30  *      }
31  */
32 int main(int argc, char *argv[])
33 {
34         /* Expect exactly one argument */
35         if (argc != 2)
36                 return 1;
37
38         if (strcmp(argv[1], "depends") == 0) {
39                 printf("ccan/tal\n");
40                 return 0;
41         }
42
43         return 1;
44 }