X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=server-src%2Ftapefile.c;fp=server-src%2Ftapefile.c;h=faf58759bb510625a11337a4c8751b035cda8552;hb=109540caa4e37a3663b3dcfb9a205b9609e3f561;hp=8e4400bf4a9d49a9a99933661fd80c2bf3c26317;hpb=4c9eba1feb11adf189bceb4001c425e641f0b56a;p=debian%2Famanda diff --git a/server-src/tapefile.c b/server-src/tapefile.c index 8e4400b..faf5875 100644 --- a/server-src/tapefile.c +++ b/server-src/tapefile.c @@ -50,7 +50,7 @@ read_tapelist( char *line = NULL; int status = 0; - tape_list = NULL; + clear_tapelist(); if((tapef = fopen(tapefile,"r")) == NULL) { if (errno == ENOENT) { /* no tapelist is equivalent to an empty tapelist */ @@ -132,6 +132,9 @@ clear_tapelist(void) for(tp = tape_list; tp; tp = next) { amfree(tp->label); amfree(tp->datestamp); + amfree(tp->barcode); + amfree(tp->meta); + amfree(tp->comment); next = tp->next; amfree(tp); } @@ -275,6 +278,9 @@ remove_tapelabel( } amfree(tp->datestamp); amfree(tp->label); + amfree(tp->meta); + amfree(tp->comment); + amfree(tp->barcode); amfree(tp); } } @@ -289,7 +295,7 @@ add_tapelabel( /* insert a new record to the front of the list */ - new = (tape_t *) alloc(SIZEOF(tape_t)); + new = g_new0(tape_t, 1); new->datestamp = stralloc(datestamp); new->position = 0; @@ -362,19 +368,17 @@ parse_tapeline( int ch; *status = 0; - tp = (tape_t *) alloc(SIZEOF(tape_t)); - - tp->prev = NULL; - tp->next = NULL; s = line; ch = *s++; skip_whitespace(s, ch); if(ch == '\0') { - amfree(tp); return NULL; } + + tp = g_new0(tape_t, 1); + s1 = s - 1; skip_non_whitespace(s, ch); s[-1] = '\0'; @@ -409,8 +413,6 @@ parse_tapeline( s[-1] = '\0'; skip_whitespace(s, ch); tp->barcode = stralloc(s1); - } else { - tp->barcode = NULL; } if (strncmp_const(s - 1, "META:") == 0) { @@ -419,8 +421,6 @@ parse_tapeline( s[-1] = '\0'; skip_whitespace(s, ch); tp->meta = stralloc(s1); - } else { - tp->meta = NULL; } if (strncmp_const(s - 1, "BLOCKSIZE:") == 0) { @@ -429,13 +429,9 @@ parse_tapeline( s[-1] = '\0'; skip_whitespace(s, ch); tp->blocksize = atol(s1); - } else { - tp->blocksize = 0; } if (*(s - 1) == '#') { tp->comment = stralloc(s); /* skip leading '#' */ - } else { - tp->comment = NULL; } return tp;