From 7c31faa0963f0354ff711d88c54a26a4f05f5536 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sun, 12 Feb 2012 02:12:52 +0100 Subject: [PATCH] Fix graph datas calloc and SLIST_INSERT_TAIL --- src/status.c | 4 +++- src/util.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/status.c b/src/status.c index 8f0695d..7a60505 100644 --- a/src/status.c +++ b/src/status.c @@ -114,7 +114,7 @@ status_graph_process(struct status_ctx *ctx, struct status_seq *sq, char *name) gc = xcalloc(1, sizeof(struct status_gcache)); gc->name = xstrdup(name); gc->ndata = 1; - gc->datas = xcalloc(sq->geo.w + sq->geo.w, sizeof(int)); + gc->datas = xcalloc(sq->geo.w << 2, sizeof(int)); gc->datas[0] = sq->data[1]; SLIST_INSERT_HEAD(&ctx->gcache, gc, next); @@ -487,6 +487,8 @@ status_flush_list(struct status_ctx *ctx) free(sq->str); free(sq); } + + SLIST_INIT(&ctx->statushead); } void diff --git a/src/util.h b/src/util.h index c2431e2..3b6c82c 100644 --- a/src/util.h +++ b/src/util.h @@ -23,7 +23,7 @@ /* Insert at the end with SLIST */ #define SLIST_INSERT_TAIL(head, elem, field, prev) \ - if(SLIST_EMPTY(head)) \ + if(!prev) \ SLIST_INSERT_HEAD(head, elem, field); \ else \ SLIST_INSERT_AFTER(prev, elem, field);