X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fblock_pool%2F_info;fp=ccan%2Fblock_pool%2F_info;h=53afc7bd8826e5a3474392548c1af31458b8559f;hb=2622d34405aa838770d9c72c523db4ed8defadaa;hp=0000000000000000000000000000000000000000;hpb=2356c14ecbb57ae1e335eb46b3c8ea78ea3f28bb;p=ccan diff --git a/ccan/block_pool/_info b/ccan/block_pool/_info new file mode 100644 index 00000000..53afc7bd --- /dev/null +++ b/ccan/block_pool/_info @@ -0,0 +1,51 @@ +#include +#include +#include "config.h" + +/** + * block_pool - An efficient allocator for blocks that don't need to be + * resized or freed. + * + * block_pool allocates blocks by packing them into buffers, making the + * overhead per block virtually zero. Because of this, you cannot resize or + * free individual blocks, but you can free the entire block_pool. + * + * The rationale behind block_pool is that talloc uses a lot of bytes per + * block (48 on 32-bit, 80 on 64-bit). Nevertheless, talloc is an excellent + * tool for C programmers of all ages. Because a block_pool is a talloc + * context, it can be useful in talloc-based applications where many small + * blocks need to be allocated. + * + * Example: + * + * #include + * + * int main(void) { + * struct block_pool *bp = block_pool_new(NULL); + * + * void *buffer = block_pool_alloc(bp, 4096); + * char *string = block_pool_strdup(bp, "A string"); + * + * int array[] = {0,1,1,2,3,5,8,13,21,34}; + * int *array_copy = block_pool_memdup(bp, array, sizeof(array)); + * + * block_pool_free(bp); + * return 0; + * } + * + * Author: Joey Adams + * License: BSD + */ +int main(int argc, char *argv[]) +{ + /* Expect exactly one argument */ + if (argc != 2) + return 1; + + if (strcmp(argv[1], "depends") == 0) { + printf("ccan/talloc\n"); + return 0; + } + + return 1; +}