From ae630ed595330f102685bbbb96c01a8c24b8923a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 31 Mar 2019 00:11:05 +0100 Subject: Add cval field to LLIST. --- src/guile_interface.scm.c | 6 +++--- src/linked_list.h | 1 + src/linked_list.inc.h | 3 +++ src/main.c | 2 +- src/vcal.c | 4 ++-- src/vcal.h | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/guile_interface.scm.c b/src/guile_interface.scm.c index a9485b38..9356533d 100644 --- a/src/guile_interface.scm.c +++ b/src/guile_interface.scm.c @@ -89,14 +89,14 @@ SCM_DEFINE (vcomponent_set_attr_x, "%vcomponent-set-attribute!", 3, 0, 0, * Otherwise we know that it's NULL and safe to write a new * SCM value there. */ - if (c->cur->value->key.scm != NULL) { - scm_gc_unprotect_object(c->cur->value->key.scm); + if (c->cval->key.scm != NULL) { + scm_gc_unprotect_object(c->cval->key.scm); } } free(key); - strbuf* target = &c->cur->value->key; + strbuf* target = &c->cval->key; target->scm = new_value; scm_gc_protect_object(target->scm); diff --git a/src/linked_list.h b/src/linked_list.h index ec1e17e0..0d32b988 100644 --- a/src/linked_list.h +++ b/src/linked_list.h @@ -23,6 +23,7 @@ typedef struct { LINK(TYPE)* head; LINK(TYPE)* tail; LINK(TYPE)* cur; + TYPE* cval; int length; } LLIST(TYPE); diff --git a/src/linked_list.inc.h b/src/linked_list.inc.h index 81974a9c..3984e485 100644 --- a/src/linked_list.inc.h +++ b/src/linked_list.inc.h @@ -11,6 +11,7 @@ INIT_F ( LLIST(TYPE) ) { head->after = tail; tail->before = head; self->cur = head; + self->cval = head->value; return 0; } @@ -69,6 +70,7 @@ int PUSH(LLIST(TYPE)) ( LLIST(TYPE)* lst, TYPE* val) { // TODO do I want to change that? lst->cur = link; + lst->cval = link->value; return 0; } @@ -157,6 +159,7 @@ int RESET(LLIST(TYPE)) ( LLIST(TYPE)* llist ) { } llist->cur = llist->head; + llist->cval = llist->head->value; return 0; } diff --git a/src/main.c b/src/main.c index f086f6f9..40dc705f 100644 --- a/src/main.c +++ b/src/main.c @@ -84,7 +84,7 @@ int main (int argc, char** argv) { printf("%s | %s\n", filename, - get_property(ev, "SUMMARY")->cur->value->key.mem); + get_property(ev, "SUMMARY")->cval->key.mem); } } } else if (strcmp(args.argv[0], "-g") == 0) { diff --git a/src/vcal.c b/src/vcal.c index 2a610187..297ed52e 100644 --- a/src/vcal.c +++ b/src/vcal.c @@ -164,8 +164,8 @@ char* vcomponent_get_val (vcomponent* comp, const char* key) { content_line* cl = GET(TRIE(content_line))(&comp->clines, key_cpy); free (key_cpy); - if (cl != NULL && cl->cur->value != NULL) { - return cl->cur->value->key.mem; + if (cl != NULL && cl->cval != NULL) { + return cl->cval->key.mem; } return NULL; diff --git a/src/vcal.h b/src/vcal.h index 3db5fcdc..eff1f06f 100644 --- a/src/vcal.h +++ b/src/vcal.h @@ -48,7 +48,7 @@ */ /* content_set */ -#define CLINE_CUR(c) ((c)->cur->value) +#define CLINE_CUR(c) ((c)->cval) /* strbuf */ #define CLINE_CUR_VAL(c) (& CLINE_CUR(c)->key) -- cgit v1.2.3