diff --git a/libs/libks/test/testpools b/libs/libks/test/testpools new file mode 100755 index 0000000000..7b08d632e5 Binary files /dev/null and b/libs/libks/test/testpools differ diff --git a/libs/libks/test/testpools.c b/libs/libks/test/testpools.c new file mode 100644 index 0000000000..48580a0525 --- /dev/null +++ b/libs/libks/test/testpools.c @@ -0,0 +1,47 @@ +#include +#include +#include "mpool.h" +#include + +int main(int argc, char **argv) +{ + mpool_t *pool; + int err = 0; + char *str = NULL; + int x = 0; + int bytes = 1024; + + if (argc > 1) { + int tmp = atoi(argv[1]); + + if (tmp > 0) { + bytes = tmp; + } else { + fprintf(stderr, "INVALID\n"); + exit(255); + } + } + + pool = mpool_open(MPOOL_FLAG_ANONYMOUS, 0, NULL, &err); + + if (!pool || err != MPOOL_ERROR_NONE) { + fprintf(stderr, "ERR: %d [%s]\n", err, mpool_strerror(err)); + exit(255); + } + + str = mpool_alloc(pool, bytes, &err); + memset(str+x, '.', bytes -1); + *(str+(bytes-1)) = '\0'; + + printf("%s\n", str); + + //mpool_clear(pool); + err = mpool_close(pool); + + if (err != MPOOL_ERROR_NONE) { + fprintf(stderr, "ERR: [%s]\n", mpool_strerror(err)); + exit(255); + } + + exit(0); +}