diff --git a/Arena.cc b/Arena.cc index feaabe8..5eae512 100644 --- a/Arena.cc +++ b/Arena.cc @@ -69,18 +69,18 @@ AllocNewArena(Arena & arena, size_t size) #if defined(__linux__) int -MMapArena(Arena &arena, int fd, size_t Size) +MMapArena(Arena &arena, int fd, size_t size) { if (arena.Size > 0) { - if (arena_destroy(arena) != 0) { + if (DestroyArena(arena) != 0) { return -1; } } arena.Type = ARENA_MMAP; - arena.Size = Size; - arena.store = (uint8_t *)mmap(NULL, Size, PROT_RW, MAP_SHARED, fd, 0); - if ((void *)arena.store == MAP_FAILED) { + arena.Size = size; + arena.Store = (uint8_t *)mmap(NULL, size, PROT_RW, MAP_SHARED, fd, 0); + if ((void *)arena.Store == MAP_FAILED) { return -1; } arena.fd = fd; @@ -94,7 +94,7 @@ OpenArena(Arena &arena, const char *path) struct stat st; if (arena.Size > 0) { - if (arena_destroy(arena) != 0) { + if (DestroyArena(arena) != 0) { return -1; } } @@ -113,12 +113,12 @@ OpenArena(Arena &arena, const char *path) int -CreateArena(Arena &arena, const char *path, size_t Size, mode_t mode) +CreateArena(Arena &arena, const char *path, size_t size, mode_t mode) { int fd = 0; if (arena.Size > 0) { - if (arena_destroy(arena) != 0) { + if (DestroyArena(arena) != 0) { return -1; } } @@ -128,7 +128,7 @@ CreateArena(Arena &arena, const char *path, size_t Size, mode_t mode) return -1; } - if (ftruncate(fd, Size) == -1) { + if (ftruncate(fd, size) == -1) { return -1; } @@ -170,7 +170,7 @@ DestroyArena(Arena &arena) break; #if defined(__linux__) case ARENA_MMAP: - if (munmap(arena.store, arena.Size) == -1) { + if (munmap(arena.Store, arena.Size) == -1) { return -1; } @@ -219,7 +219,7 @@ DisplayArena(const Arena &arena) break; #if defined(__linux__) case ARENA_MMAP: - std::cout << "mmap/file" + std::cout << "mmap/file"; break; #endif default: diff --git a/Arena.h b/Arena.h index 61be019..10fbae0 100644 --- a/Arena.h +++ b/Arena.h @@ -38,8 +38,7 @@ int DestroyArena(Arena &); /* dispose of any memory used by arena */ * BACKING FILE! */ int WriteArena(const Arena &arena, const char *path); -void -DisplayArena(const Arena &arena); +void DisplayArena(const Arena &arena); #endif diff --git a/Dictionary.cc b/Dictionary.cc index 6d50552..8deadad 100644 --- a/Dictionary.cc +++ b/Dictionary.cc @@ -135,17 +135,17 @@ Dictionary::DumpKVPairs() } } +#else +void +Dictionary::DumpKVPairs() +{ + +} +#endif + void Dictionary::DumpToFile(const char *path) { WriteArena(this->arena, path); } - -#else -void -Dictionary::dump_kvpairs() -{ - -} -#endif diff --git a/Makefile b/Makefile index cb720d5..6a69b5c 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ SOURCES := $(wildcard *.cc) OBJS := Arena.o Dictionary.o TLV.o CXX := clang++ -CXXFLAGS := -g -std=c++14 -Werror -Wall +CXXFLAGS := -g -std=c++14 -Werror -Wall -DDESKTOP_BUILD .PHONY: all all: $(TARGET) $(TESTS) tags run-tests @@ -17,10 +17,10 @@ $(TARGET): $(OBJS) $(AR) rcs $@ $(OBJS) tlv_test: tlvTest.o $(TARGET) - $(CXX) -o $@ $(CXXFLAGS) $@.o $(TARGET) + $(CXX) -o $@ $(CXXFLAGS) tlvTest.o $(TARGET) dictionary_test: dictionaryTest.o $(TARGET) - $(CXX) -o $@ $(CXXFLAGS) $@.o $(TARGET) + $(CXX) -o $@ $(CXXFLAGS) dictionaryTest.o $(TARGET) .PHONY: print-% print-%: ; @echo '$(subst ','\'',$*=$($*))' diff --git a/dictionary_test b/dictionary_test new file mode 100755 index 0000000..5f983a1 Binary files /dev/null and b/dictionary_test differ diff --git a/testFixtures.h b/testFixtures.h index 141dd60..31b743b 100644 --- a/testFixtures.h +++ b/testFixtures.h @@ -2,6 +2,9 @@ #define KLIB_TESTFIXTURES_H +#include + + #define ARENA_SIZE 128 #define ARENA_FILE "arena_test.bin" diff --git a/tlvTest.cc b/tlvTest.cc index ce269da..2e1ea84 100644 --- a/tlvTest.cc +++ b/tlvTest.cc @@ -97,7 +97,7 @@ main(int argc, const char *argv[]) if (-1 == CreateArena(arenaFile, ARENA_FILE, ARENA_SIZE, 0644)) { abort(); - } else if (!run_suite(arenaFile, "arenaFile")) { + } else if (!runSuite(arenaFile, "arenaFile")) { abort(); } #endif diff --git a/tlv_test b/tlv_test new file mode 100755 index 0000000..afab545 Binary files /dev/null and b/tlv_test differ