Parcourir la source

Fix graph datas calloc and SLIST_INSERT_TAIL

Martin Duquesnoy il y a 12 ans
Parent
commit
7c31faa096
2 fichiers modifiés avec 4 ajouts et 2 suppressions
  1. 3 1
      src/status.c
  2. 1 1
      src/util.h

+ 3 - 1
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

+ 1 - 1
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);