Loading .gitmodules +0 −4 Original line number Diff line number Diff line Loading @@ -10,7 +10,3 @@ path = vendor/socket99 url = https://github.com/silentbicycle/socket99.git branch = master [submodule "zlog"] path = vendor/zlog url = https://github.com/zma/zlog.git branch = master Makefile +0 −6 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ LIB_DIR = ./src/lib VENDOR = ./vendor PROTOBUFC = $(VENDOR)/protobuf-c SOCKET99 = $(VENDOR)/socket99 ZLOG = $(VENDOR)/zlog VERSION_FILE = ./VERSION VERSION = ${shell head -n1 $(VERSION_FILE)} Loading @@ -37,8 +36,6 @@ KINETIC_LIB = $(BIN_DIR)/lib$(KINETIC_LIB_NAME).a LIB_INCS = -I$(LIB_DIR) -I$(PUB_INC) -I$(PROTOBUFC) -I$(VENDOR) LIB_DEPS = \ $(PROTOBUFC)/protobuf-c/protobuf-c.h \ $(ZLOG)/zlog.h \ $(ZLOG)/zlog-config.h \ $(SOCKET99)/socket99.h \ $(LIB_DIR)/kinetic_allocator.h \ $(LIB_DIR)/kinetic_nbo.h \ Loading @@ -59,7 +56,6 @@ LIB_DEPS = \ LIB_OBJS = \ $(OUT_DIR)/socket99.o \ $(OUT_DIR)/protobuf-c.o \ $(OUT_DIR)/zlog.o \ $(OUT_DIR)/kinetic_allocator.o \ $(OUT_DIR)/kinetic_nbo.o \ $(OUT_DIR)/kinetic_operation.o \ Loading Loading @@ -93,8 +89,6 @@ $(OUT_DIR)/socket99.o: $(SOCKET99)/socket99.c $(SOCKET99)/socket99.h $(CC) -c -o $@ $< $(CFLAGS) -I$(SOCKET99) $(OUT_DIR)/protobuf-c.o: $(PROTOBUFC)/protobuf-c/protobuf-c.c $(PROTOBUFC)/protobuf-c/protobuf-c.h $(CC) -c -o $@ $< -std=c99 -fPIC -g -Wall $(OPTIMIZE) -Wno-unused-parameter -I$(PROTOBUFC) $(OUT_DIR)/zlog.o: $(ZLOG)/zlog.c $(ZLOG)/zlog.h $(ZLOG)/zlog-config.h $(CC) -c -o $@ $< $(CFLAGS) -I$(ZLOG) $(OUT_DIR)/kinetic_allocator.o: $(LIB_DIR)/kinetic_allocator.c $(LIB_DEPS) $(CC) -c -o $@ $< $(CFLAGS) $(LIB_INCS) $(OUT_DIR)/kinetic_nbo.o: $(LIB_DIR)/kinetic_nbo.c $(LIB_DEPS) Loading Rakefile +0 −1 Original line number Diff line number Diff line Loading @@ -130,7 +130,6 @@ namespace :doxygen do end namespace :java_sim do JAVA_HOME = ENV.fetch('JAVA_HOME', '/usr') JAVA_BIN = File.join(JAVA_HOME, 'bin/java') $java_sim = nil Loading project.yml +0 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ - src/utility/** - vendor/protobuf-c/protobuf-c/protobuf-c.c - vendor/socket99/socket99.c - vendor/zlog/zlog.c :include: - src/** - include/** Loading src/lib/kinetic_allocator.c +32 −58 Original line number Diff line number Diff line Loading @@ -23,8 +23,6 @@ #include <stdlib.h> #include <pthread.h> // #define KINETIC_LOG_ALLOCATOR static inline void KineticAllocator_LockList(KineticList* const list) { assert(!list->locked); Loading @@ -51,13 +49,13 @@ static void* KineticAllocator_NewItem(KineticList* const list, size_t size) { KineticListItem* newItem = (KineticListItem*)malloc(sizeof(KineticListItem)); if (newItem == NULL) { LOG("Failed allocating new list item!"); LOG0("Failed allocating new list item!"); return NULL; } memset(newItem, 0, sizeof(KineticListItem)); newItem->data = malloc(size); if (newItem->data == NULL) { LOG("Failed allocating data for list item!"); LOG0("Failed allocating data for list item!"); return NULL; } memset(newItem->data, 0, size); Loading @@ -74,10 +72,8 @@ static void* KineticAllocator_NewItem(KineticList* const list, size_t size) list->last = newItem; KineticAllocator_UnlockList(list); #ifdef KINETIC_LOG_ALLOCATOR LOGF("Allocated new list item @ 0x%0llX w/data @ 0x%0llX", LOGF2("Allocated new list item @ 0x%0llX w/data @ 0x%0llX", (long long)newItem, (long long)newItem->data); #endif return newItem->data; } Loading @@ -88,7 +84,7 @@ static void KineticAllocator_FreeItem(KineticList* const list, void* item) KineticListItem* cur = list->start; while (cur->data != item) { if (cur->next == NULL) { LOG(" Reached end of list before finding item to free!"); LOG1(" Reached end of list before finding item to free!"); KineticAllocator_UnlockList(list); return; } Loading @@ -96,51 +92,49 @@ static void KineticAllocator_FreeItem(KineticList* const list, void* item) cur = cur->next; } } // LOG(" Done searching for item list item"); LOG2(" Done searching for item list item"); if ((cur != NULL) && (cur->data == item)) { // LOG(" item found! freeing it."); LOG2(" item found! freeing it."); // Handle PDU list emptied if (cur->previous == NULL) { // LOG(" At start of list."); LOG2(" At start of list."); if (cur->next == NULL) { // LOG(" Making it empty, since all deallocated!"); LOG2(" Making it empty, since all deallocated!"); list->start = NULL; list->last = NULL; } else { // LOG(" Moving current item to head, since head deallocated!"); LOG2(" Moving current item to head, since head deallocated!"); list->start = cur->next; list->start->previous = NULL; } } else { // Relink from previous to next, if avaliable // LOG(" Not at list start, so relinking list to free item."); LOG2(" Not at list start, so relinking list to free item."); if (cur->previous->next != NULL) { // LOG(" Relinking previous to next"); LOG2(" Relinking previous to next"); if (cur->next != NULL) { // LOG(" next being reset!"); LOG2(" next being reset!"); cur->previous->next = cur->next; } else { list->last = cur->previous; list->last->next = NULL; // LOGF(" next is NULL. End of list now @ 0x%0llX", // (long long)list->last); LOGF2(" next is NULL. End of list now @ 0x%0llX", (long long)list->last); } } else { LOG(" This shouldn't happen!"); LOG1(" This shouldn't happen!"); list->last = cur->previous; } } #ifdef KINETIC_LOG_ALLOCATOR LOGF(" Freeing item @ 0x%0llX, item @ 0x%0llX", LOGF2(" Freeing item @ 0x%0llX, item @ 0x%0llX", (long long)cur, (long long)&cur->data); #endif free(cur->data); cur->data = NULL; free(cur); Loading @@ -152,42 +146,32 @@ static void KineticAllocator_FreeItem(KineticList* const list, void* item) static void KineticAllocator_FreeList(KineticList* const list) { if (list != NULL) { #ifdef KINETIC_LOG_ALLOCATOR LOG("Freeing list of all items"); #endif LOG2("Freeing list of all items"); KineticAllocator_LockList(list); KineticListItem* current = list->start; while (current->next != NULL) { #ifdef KINETIC_LOG_ALLOCATOR LOG("Advancing to next list item..."); #endif LOG2("Advancing to next list item..."); current = current->next; } while (current != NULL) { #ifdef KINETIC_LOG_ALLOCATOR LOG(" Current item not freed!"); LOGF(" DEALLOCATING item: 0x%0llX, data: 0x%llX, prev: 0x%0llX", (long long)current, (long long)¤t->data, (long long)current->previous); #endif LOG2(" Current item not freed!"); LOGF2(" DEALLOCATING item: 0x%0llX, data: 0x%llX, prev: 0x%0llX", (long long)current, (long long)¤t->data, (long long)current->previous); KineticListItem* curItem = current; KineticListItem* prevItem = current->previous; if (curItem != NULL) { #ifdef KINETIC_LOG_ALLOCATOR LOG(" Freeing list item"); #endif LOG2(" Freeing list item"); if (curItem->data != NULL) { free(curItem->data); } free(curItem); } current = prevItem; #ifdef KINETIC_LOG_ALLOCATOR LOGF(" on to prev=0x%llX", (long long)current); #endif LOGF2(" on to prev=0x%llX", (long long)current); } *list = (KineticList) { Loading @@ -197,9 +181,7 @@ static void KineticAllocator_FreeList(KineticList* const list) KineticAllocator_UnlockList(list); } else { #ifdef KINETIC_LOG_ALLOCATOR LOG(" Nothing to free!"); #endif LOG1(" Nothing to free!"); } } Loading @@ -210,14 +192,12 @@ KineticPDU* KineticAllocator_NewPDU(KineticList* const list, KineticConnection* KineticPDU* newPDU = (KineticPDU*)KineticAllocator_NewItem( list, sizeof(KineticPDU)); if (newPDU == NULL) { LOG("Failed allocating new PDU!"); LOG0("Failed allocating new PDU!"); return NULL; } assert(newPDU->proto == NULL); KINETIC_PDU_INIT(newPDU, connection); #ifdef KINETIC_LOG_ALLOCATOR LOGF("Allocated new PDU @ 0x%0llX", (long long)newPDU); #endif LOGF2("Allocated new PDU @ 0x%0llX", (long long)newPDU); return newPDU; } Loading @@ -225,9 +205,7 @@ void KineticAllocator_FreePDU(KineticList* const list, KineticPDU* pdu) { KineticAllocator_LockList(list); if ((pdu->proto != NULL) && pdu->protobufDynamicallyExtracted) { #ifdef KINETIC_LOG_ALLOCATOR LOG("Freeing dynamically allocated protobuf"); #endif LOG2("Freeing dynamically allocated protobuf"); KineticProto_Message__free_unpacked(pdu->proto, NULL); }; KineticAllocator_UnlockList(list); Loading Loading @@ -268,7 +246,7 @@ KineticPDU* KineticAllocator_GetNextPDU(KineticList* const list, KineticPDU* pdu void KineticAllocator_FreeAllPDUs(KineticList* const list) { if (list->start != NULL) { LOG("Freeing all PDUs..."); LOG2("Freeing all PDUs..."); KineticAllocator_LockList(list); KineticListItem* current = list->start; while (current != NULL) { Loading @@ -283,18 +261,14 @@ void KineticAllocator_FreeAllPDUs(KineticList* const list) KineticAllocator_FreeList(list); } else { #ifdef KINETIC_LOG_ALLOCATOR LOG(" Nothing to free!"); #endif LOG1(" Nothing to free!"); } } bool KineticAllocator_ValidateAllMemoryFreed(KineticList* const list) { bool empty = (list->start == NULL); #ifdef KINETIC_LOG_ALLOCATOR LOGF(" PDUList: 0x%0llX, empty=%s", LOGF2(" PDUList: 0x%0llX, empty=%s", (long long)list->start, empty ? "true" : "false"); #endif return empty; } Loading
.gitmodules +0 −4 Original line number Diff line number Diff line Loading @@ -10,7 +10,3 @@ path = vendor/socket99 url = https://github.com/silentbicycle/socket99.git branch = master [submodule "zlog"] path = vendor/zlog url = https://github.com/zma/zlog.git branch = master
Makefile +0 −6 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ LIB_DIR = ./src/lib VENDOR = ./vendor PROTOBUFC = $(VENDOR)/protobuf-c SOCKET99 = $(VENDOR)/socket99 ZLOG = $(VENDOR)/zlog VERSION_FILE = ./VERSION VERSION = ${shell head -n1 $(VERSION_FILE)} Loading @@ -37,8 +36,6 @@ KINETIC_LIB = $(BIN_DIR)/lib$(KINETIC_LIB_NAME).a LIB_INCS = -I$(LIB_DIR) -I$(PUB_INC) -I$(PROTOBUFC) -I$(VENDOR) LIB_DEPS = \ $(PROTOBUFC)/protobuf-c/protobuf-c.h \ $(ZLOG)/zlog.h \ $(ZLOG)/zlog-config.h \ $(SOCKET99)/socket99.h \ $(LIB_DIR)/kinetic_allocator.h \ $(LIB_DIR)/kinetic_nbo.h \ Loading @@ -59,7 +56,6 @@ LIB_DEPS = \ LIB_OBJS = \ $(OUT_DIR)/socket99.o \ $(OUT_DIR)/protobuf-c.o \ $(OUT_DIR)/zlog.o \ $(OUT_DIR)/kinetic_allocator.o \ $(OUT_DIR)/kinetic_nbo.o \ $(OUT_DIR)/kinetic_operation.o \ Loading Loading @@ -93,8 +89,6 @@ $(OUT_DIR)/socket99.o: $(SOCKET99)/socket99.c $(SOCKET99)/socket99.h $(CC) -c -o $@ $< $(CFLAGS) -I$(SOCKET99) $(OUT_DIR)/protobuf-c.o: $(PROTOBUFC)/protobuf-c/protobuf-c.c $(PROTOBUFC)/protobuf-c/protobuf-c.h $(CC) -c -o $@ $< -std=c99 -fPIC -g -Wall $(OPTIMIZE) -Wno-unused-parameter -I$(PROTOBUFC) $(OUT_DIR)/zlog.o: $(ZLOG)/zlog.c $(ZLOG)/zlog.h $(ZLOG)/zlog-config.h $(CC) -c -o $@ $< $(CFLAGS) -I$(ZLOG) $(OUT_DIR)/kinetic_allocator.o: $(LIB_DIR)/kinetic_allocator.c $(LIB_DEPS) $(CC) -c -o $@ $< $(CFLAGS) $(LIB_INCS) $(OUT_DIR)/kinetic_nbo.o: $(LIB_DIR)/kinetic_nbo.c $(LIB_DEPS) Loading
Rakefile +0 −1 Original line number Diff line number Diff line Loading @@ -130,7 +130,6 @@ namespace :doxygen do end namespace :java_sim do JAVA_HOME = ENV.fetch('JAVA_HOME', '/usr') JAVA_BIN = File.join(JAVA_HOME, 'bin/java') $java_sim = nil Loading
project.yml +0 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ - src/utility/** - vendor/protobuf-c/protobuf-c/protobuf-c.c - vendor/socket99/socket99.c - vendor/zlog/zlog.c :include: - src/** - include/** Loading
src/lib/kinetic_allocator.c +32 −58 Original line number Diff line number Diff line Loading @@ -23,8 +23,6 @@ #include <stdlib.h> #include <pthread.h> // #define KINETIC_LOG_ALLOCATOR static inline void KineticAllocator_LockList(KineticList* const list) { assert(!list->locked); Loading @@ -51,13 +49,13 @@ static void* KineticAllocator_NewItem(KineticList* const list, size_t size) { KineticListItem* newItem = (KineticListItem*)malloc(sizeof(KineticListItem)); if (newItem == NULL) { LOG("Failed allocating new list item!"); LOG0("Failed allocating new list item!"); return NULL; } memset(newItem, 0, sizeof(KineticListItem)); newItem->data = malloc(size); if (newItem->data == NULL) { LOG("Failed allocating data for list item!"); LOG0("Failed allocating data for list item!"); return NULL; } memset(newItem->data, 0, size); Loading @@ -74,10 +72,8 @@ static void* KineticAllocator_NewItem(KineticList* const list, size_t size) list->last = newItem; KineticAllocator_UnlockList(list); #ifdef KINETIC_LOG_ALLOCATOR LOGF("Allocated new list item @ 0x%0llX w/data @ 0x%0llX", LOGF2("Allocated new list item @ 0x%0llX w/data @ 0x%0llX", (long long)newItem, (long long)newItem->data); #endif return newItem->data; } Loading @@ -88,7 +84,7 @@ static void KineticAllocator_FreeItem(KineticList* const list, void* item) KineticListItem* cur = list->start; while (cur->data != item) { if (cur->next == NULL) { LOG(" Reached end of list before finding item to free!"); LOG1(" Reached end of list before finding item to free!"); KineticAllocator_UnlockList(list); return; } Loading @@ -96,51 +92,49 @@ static void KineticAllocator_FreeItem(KineticList* const list, void* item) cur = cur->next; } } // LOG(" Done searching for item list item"); LOG2(" Done searching for item list item"); if ((cur != NULL) && (cur->data == item)) { // LOG(" item found! freeing it."); LOG2(" item found! freeing it."); // Handle PDU list emptied if (cur->previous == NULL) { // LOG(" At start of list."); LOG2(" At start of list."); if (cur->next == NULL) { // LOG(" Making it empty, since all deallocated!"); LOG2(" Making it empty, since all deallocated!"); list->start = NULL; list->last = NULL; } else { // LOG(" Moving current item to head, since head deallocated!"); LOG2(" Moving current item to head, since head deallocated!"); list->start = cur->next; list->start->previous = NULL; } } else { // Relink from previous to next, if avaliable // LOG(" Not at list start, so relinking list to free item."); LOG2(" Not at list start, so relinking list to free item."); if (cur->previous->next != NULL) { // LOG(" Relinking previous to next"); LOG2(" Relinking previous to next"); if (cur->next != NULL) { // LOG(" next being reset!"); LOG2(" next being reset!"); cur->previous->next = cur->next; } else { list->last = cur->previous; list->last->next = NULL; // LOGF(" next is NULL. End of list now @ 0x%0llX", // (long long)list->last); LOGF2(" next is NULL. End of list now @ 0x%0llX", (long long)list->last); } } else { LOG(" This shouldn't happen!"); LOG1(" This shouldn't happen!"); list->last = cur->previous; } } #ifdef KINETIC_LOG_ALLOCATOR LOGF(" Freeing item @ 0x%0llX, item @ 0x%0llX", LOGF2(" Freeing item @ 0x%0llX, item @ 0x%0llX", (long long)cur, (long long)&cur->data); #endif free(cur->data); cur->data = NULL; free(cur); Loading @@ -152,42 +146,32 @@ static void KineticAllocator_FreeItem(KineticList* const list, void* item) static void KineticAllocator_FreeList(KineticList* const list) { if (list != NULL) { #ifdef KINETIC_LOG_ALLOCATOR LOG("Freeing list of all items"); #endif LOG2("Freeing list of all items"); KineticAllocator_LockList(list); KineticListItem* current = list->start; while (current->next != NULL) { #ifdef KINETIC_LOG_ALLOCATOR LOG("Advancing to next list item..."); #endif LOG2("Advancing to next list item..."); current = current->next; } while (current != NULL) { #ifdef KINETIC_LOG_ALLOCATOR LOG(" Current item not freed!"); LOGF(" DEALLOCATING item: 0x%0llX, data: 0x%llX, prev: 0x%0llX", (long long)current, (long long)¤t->data, (long long)current->previous); #endif LOG2(" Current item not freed!"); LOGF2(" DEALLOCATING item: 0x%0llX, data: 0x%llX, prev: 0x%0llX", (long long)current, (long long)¤t->data, (long long)current->previous); KineticListItem* curItem = current; KineticListItem* prevItem = current->previous; if (curItem != NULL) { #ifdef KINETIC_LOG_ALLOCATOR LOG(" Freeing list item"); #endif LOG2(" Freeing list item"); if (curItem->data != NULL) { free(curItem->data); } free(curItem); } current = prevItem; #ifdef KINETIC_LOG_ALLOCATOR LOGF(" on to prev=0x%llX", (long long)current); #endif LOGF2(" on to prev=0x%llX", (long long)current); } *list = (KineticList) { Loading @@ -197,9 +181,7 @@ static void KineticAllocator_FreeList(KineticList* const list) KineticAllocator_UnlockList(list); } else { #ifdef KINETIC_LOG_ALLOCATOR LOG(" Nothing to free!"); #endif LOG1(" Nothing to free!"); } } Loading @@ -210,14 +192,12 @@ KineticPDU* KineticAllocator_NewPDU(KineticList* const list, KineticConnection* KineticPDU* newPDU = (KineticPDU*)KineticAllocator_NewItem( list, sizeof(KineticPDU)); if (newPDU == NULL) { LOG("Failed allocating new PDU!"); LOG0("Failed allocating new PDU!"); return NULL; } assert(newPDU->proto == NULL); KINETIC_PDU_INIT(newPDU, connection); #ifdef KINETIC_LOG_ALLOCATOR LOGF("Allocated new PDU @ 0x%0llX", (long long)newPDU); #endif LOGF2("Allocated new PDU @ 0x%0llX", (long long)newPDU); return newPDU; } Loading @@ -225,9 +205,7 @@ void KineticAllocator_FreePDU(KineticList* const list, KineticPDU* pdu) { KineticAllocator_LockList(list); if ((pdu->proto != NULL) && pdu->protobufDynamicallyExtracted) { #ifdef KINETIC_LOG_ALLOCATOR LOG("Freeing dynamically allocated protobuf"); #endif LOG2("Freeing dynamically allocated protobuf"); KineticProto_Message__free_unpacked(pdu->proto, NULL); }; KineticAllocator_UnlockList(list); Loading Loading @@ -268,7 +246,7 @@ KineticPDU* KineticAllocator_GetNextPDU(KineticList* const list, KineticPDU* pdu void KineticAllocator_FreeAllPDUs(KineticList* const list) { if (list->start != NULL) { LOG("Freeing all PDUs..."); LOG2("Freeing all PDUs..."); KineticAllocator_LockList(list); KineticListItem* current = list->start; while (current != NULL) { Loading @@ -283,18 +261,14 @@ void KineticAllocator_FreeAllPDUs(KineticList* const list) KineticAllocator_FreeList(list); } else { #ifdef KINETIC_LOG_ALLOCATOR LOG(" Nothing to free!"); #endif LOG1(" Nothing to free!"); } } bool KineticAllocator_ValidateAllMemoryFreed(KineticList* const list) { bool empty = (list->start == NULL); #ifdef KINETIC_LOG_ALLOCATOR LOGF(" PDUList: 0x%0llX, empty=%s", LOGF2(" PDUList: 0x%0llX, empty=%s", (long long)list->start, empty ? "true" : "false"); #endif return empty; }