_info 1.3 KB

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