#include <stdio.h>
#include <stddef.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <time.h>
#include <loc/libloc.h>
-#include "stringpool.h"
+#include <loc/stringpool.h>
static const char* characters = "012345789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
// Create the stringpool
struct loc_stringpool* pool;
- err = loc_stringpool_new(ctx, &pool, 10002 * 4);
+ err = loc_stringpool_new(ctx, &pool);
if (err < 0)
exit(EXIT_FAILURE);
+ // Try reading some invalid string
+ const char* s = loc_stringpool_get(pool, 100);
+ if (s != NULL) {
+ fprintf(stderr, "An unexpected string was returned: %s\n", s);
+ exit(EXIT_FAILURE);
+ }
+
// Append a string
off_t pos = loc_stringpool_add(pool, "ABC");
if (pos < 0) {
exit(EXIT_FAILURE);
}
- printf("Added string at %jd\n", pos);
+ printf("Added string at %jd\n", (intmax_t)pos);
// Must start at first byte
if (pos != 0) {