diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-07-27 20:16:07 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-07-27 20:16:07 +0200 |
commit | 88ff17de1673575b247da3374dedf8561716238e (patch) | |
tree | 1302ffb5363724ece99148022fb897a8d65ef5c2 /src/libmdsserver | |
parent | mark temporary prints (diff) | |
download | mds-88ff17de1673575b247da3374dedf8561716238e.tar.gz mds-88ff17de1673575b247da3374dedf8561716238e.tar.bz2 mds-88ff17de1673575b247da3374dedf8561716238e.tar.xz |
fix multiple clients bug: minor bug in linked_list caused removal of old clients + add dump method for linked list
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/libmdsserver')
-rw-r--r-- | src/libmdsserver/linked-list.c | 37 | ||||
-rw-r--r-- | src/libmdsserver/linked-list.h | 10 |
2 files changed, 46 insertions, 1 deletions
diff --git a/src/libmdsserver/linked-list.c b/src/libmdsserver/linked-list.c index 4755ad4..066414a 100644 --- a/src/libmdsserver/linked-list.c +++ b/src/libmdsserver/linked-list.c @@ -342,7 +342,7 @@ ssize_t linked_list_insert_before(linked_list_t* restrict this, size_t value, ss if (node == LINKED_LIST_UNUSED) return LINKED_LIST_UNUSED; this->values[node] = value; - this->previous[node] = this->next[successor]; + this->previous[node] = this->previous[successor]; this->previous[successor] = node; this->next[node] = successor; this->next[this->previous[node]] = node; @@ -469,3 +469,38 @@ int linked_list_unmarshal(linked_list_t* restrict this, char* restrict data) return 0; } + +/** + * Print the content of the list + * + * @param this The list + * @param output Output file + */ +void linked_list_dump(linked_list_t* restrict this, FILE* output) +{ + ssize_t i; + size_t j; + fprintf(output, "======= LINKED LIST DUMP =======\n"); + fprintf(output, "Capacity: %lu\n", this->capacity); + fprintf(output, "End: %lu\n", this->end); + fprintf(output, "Reuse head: %lu\n", this->reuse_head); + fprintf(output, "Edge: %li\n", this->edge); + fprintf(output, "--------------------------------\n"); + fprintf(output, "Node table (Next, Prev, Value):\n"); + i = this->edge; + fprintf(output, " %li: %li, %li, %lu\n", i, this->next[i], this->previous[i], this->values[i]); + foreach_linked_list_node((*this), i) + fprintf(output, " %li: %li, %li, %lu\n", i, this->next[i], this->previous[i], this->values[i]); + i = this->edge; + fprintf(output, " %li: %li, %li, %lu\n", i, this->next[i], this->previous[i], this->values[i]); + fprintf(output, "--------------------------------\n"); + fprintf(output, "Raw node table:\n"); + for (j = 0; j < this->end; j++) + fprintf(output, " %lu: %li, %li, %lu\n", i, this->next[i], this->previous[i], this->values[i]); + fprintf(output, "--------------------------------\n"); + fprintf(output, "Reuse stack:\n"); + for (j = 0; j < this->reuse_head; j++) + fprintf(output, " %lu: %li\n", j, this->reusable[j]); + fprintf(output, "================================\n"); +} + diff --git a/src/libmdsserver/linked-list.h b/src/libmdsserver/linked-list.h index 5b1a44d..e2ec884 100644 --- a/src/libmdsserver/linked-list.h +++ b/src/libmdsserver/linked-list.h @@ -39,6 +39,7 @@ #include <stdlib.h> #include <stdint.h> +#include <stdio.h> @@ -276,5 +277,14 @@ int linked_list_unmarshal(linked_list_t* restrict this, char* restrict data); for (node = list.edge; node = list.next[node], node != list.edge;) +/** + * Print the content of the list + * + * @param this The list + * @param output Output file + */ +void linked_list_dump(linked_list_t* restrict this, FILE* output); + + #endif |