]> git.ozlabs.org Git - ccan/blob - ccan/array/_info
licence->license: US English is the standard for code.
[ccan] / ccan / array / _info
1 #include <string.h>
2 #include "config.h"
3
4 #include "ccan/array/array.h"
5
6 /**
7  * array - A collection of macros for generic dynamic array management.
8  *
9  * The array module provides generic dynamic array functions via macros.  It
10  * removes the tedium of managing realloc'd arrays with pointer, size, and
11  * allocated size.  It also fits into structures quite well.  It uses the
12  * talloc library to allocate the memory.
13  * 
14  * NOTE:  The API should be fairly stable now, but do expect small changes
15  * over time.
16  * 
17  * Example:
18  * #include <ccan/array/array.h>
19  * #include <stdio.h>
20  * 
21  * int main(void) {
22  *      array(int) numbers = array_new(NULL);
23  *      char buffer[32];
24  *      int add;
25  *      
26  *      for (;;) {
27  *              array_for(i, numbers, printf("%d ", *i));
28  *              if (numbers.size) puts("");
29  *              
30  *              printf("array> ");
31  *              fgets(buffer, sizeof(buffer), stdin);
32  *              if (*buffer==0 || *buffer=='\n')
33  *                      break;
34  *              add = atoi(buffer);
35  *              
36  *              array_append(numbers, add);
37  *      }
38  *      
39  *      array_free(numbers);
40  *      
41  *      return 0;
42  * }
43  *
44  * Author: Joey Adams
45  * Version: 0.1.1
46  * License: BSD
47  */
48 int main(int argc, char *argv[])
49 {
50         if (argc != 2)
51                 return 1;
52
53         if (strcmp(argv[1], "depends") == 0)
54                 #ifndef ARRAY_USE_TALLOC
55                 /* Nothing. */
56                 #else
57                 printf("ccan/talloc\n");
58                 #endif
59                 return 0;
60
61         return 1;
62 }