]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add test
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 4 Sep 2015 20:06:52 +0000 (15:06 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 4 Sep 2015 20:06:52 +0000 (15:06 -0500)
libs/libks/test/testpools [new file with mode: 0755]
libs/libks/test/testpools.c [new file with mode: 0644]

diff --git a/libs/libks/test/testpools b/libs/libks/test/testpools
new file mode 100755 (executable)
index 0000000..7b08d63
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 (file)
index 0000000..48580a0
--- /dev/null
@@ -0,0 +1,47 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include "mpool.h"
+#include <string.h>
+
+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);
+}