From 8596f5307ce55ff362d9d22f0b1310f341b0b1e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 23 Feb 2019 11:30:36 +0100 Subject: Something. --- linked_list.inc.h | 5 +++++ main.c | 3 ++- strbuf.c | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/linked_list.inc.h b/linked_list.inc.h index e20c6339..11c7844c 100644 --- a/linked_list.inc.h +++ b/linked_list.inc.h @@ -2,6 +2,9 @@ // #error "Set TYPE before including this file" // #else +#include +#include "err.h" + // INIT_F ( LLIST(TYPE) ) { template llist::llist () { @@ -169,8 +172,10 @@ int llist::reset () { * Manual looping rather than itterators since we destroyed the * loop variable. */ + fprintf(stderr, _RED "head = %p, tail = %p\n" _RESET, this->head, this->tail); while (link != this->tail) { next = link->after; + fprintf(stderr, _RED "link = %p\n" _RESET, link); // FFREE(LINK(TYPE), link); delete link; link = next; diff --git a/main.c b/main.c index fbd23466..91a5f423 100644 --- a/main.c +++ b/main.c @@ -60,10 +60,11 @@ int main (int argc, char** argv) { printf("component %s, [%u] children\n", ev->type, ev->components.length); if (strcmp(ev->type, "VEVENT") != 0) continue; + content_line* cl = get_property(ev, "SUMMARY"); printf("%3lu : %3lu | %s | %s\n", i + 1, j + 1, filename, - get_property(ev, "SUMMARY")->val->cur->value->key->mem); + cl->val->cur->value->key->mem); } } } else if (strcmp(args.argv[0], "-g") == 0) { diff --git a/strbuf.c b/strbuf.c index 02f29336..37b0cf3e 100644 --- a/strbuf.c +++ b/strbuf.c @@ -22,6 +22,7 @@ strbuf::strbuf () { } int strbuf_realloc(strbuf* str, size_t len) { + fprintf(stderr, "str->mem = %p\n", str->mem); str->mem = (char*) realloc(str->mem, len); str->alloc = len; return 0; @@ -66,11 +67,15 @@ int strbuf_cap(strbuf* s) { strbuf::strbuf(strbuf& src) { // int retval = 0; +#if 0 if (this->alloc < src.len) { /* +1 in length is to have room for '\0'. */ strbuf_realloc(this, src.len + 1); // retval = 1; } +#endif + + this->mem = (char*) calloc(sizeof(*this->mem), src.len + 1); this->len = src.len; memcpy(this->mem, src.mem, src.len); -- cgit v1.2.3