4 #include <prop/proplib.h>
16 * Create array object with initial capacity 10
17 * Note that the array will expand on demand
18 * by the prop_array_add() with `EXPAND_STEP' step
19 * as defined in libprop/prop_array.c
21 pa
= prop_array_create_with_capacity(10);
23 errx(EXIT_FAILURE
, "prop_array_create_with_capacity()");
26 * Add up to `NUM_STRINGS' prop_string_t objects
27 * and watch how the array expands on demand
29 for (i
= 0; i
< NUM_STRINGS
; i
++) {
30 /* Print statistics */
31 printf("count = %u\tcapacity = %u\n",
33 prop_array_capacity(pa
));
35 /* Create prop_string_t object */
36 ps
= prop_string_create_cstring_nocopy("test");
38 prop_object_release(pa
);
39 errx(EXIT_FAILURE
, "prop_string_create_cstring_nocopy()");
42 /* Add object in array */
43 if (prop_array_add(pa
, ps
) == FALSE
) {
44 prop_object_release(ps
);
45 prop_object_release(pa
);
46 errx(EXIT_FAILURE
, "prop_array_add()");
49 prop_object_release(ps
);
52 /* Release array object */
53 prop_object_release(pa
);