Remove more memory leaks caught by valgrind.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
$Id: _cdio_generic.c,v 1.12 2004/02/07 18:53:02 rocky Exp $
|
||||
$Id: _cdio_generic.c,v 1.13 2004/03/20 22:46:57 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com>
|
||||
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -27,7 +27,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.12 2004/02/07 18:53:02 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.13 2004/03/20 22:46:57 rocky Exp $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -135,8 +135,6 @@ cdio_generic_stdio_free (void *user_data)
|
||||
|
||||
if (_obj->data_source)
|
||||
cdio_stdio_destroy (_obj->data_source);
|
||||
|
||||
free (_obj);
|
||||
}
|
||||
|
||||
|
||||
@@ -177,17 +175,31 @@ cdio_add_device_list(char **device_list[], const char *drive, int *num_drives)
|
||||
{
|
||||
if (NULL != drive) {
|
||||
unsigned int j;
|
||||
|
||||
/* Check if drive is already in list. */
|
||||
for (j=0; j<*num_drives; j++) {
|
||||
if (strcmp((*device_list)[j], drive) == 0) break;
|
||||
}
|
||||
|
||||
if (j==*num_drives) {
|
||||
/* Drive not in list. Add it. */
|
||||
(*num_drives)++;
|
||||
*device_list = realloc(*device_list, (*num_drives) * sizeof(char *));
|
||||
if (*device_list) {
|
||||
*device_list = realloc(*device_list, (*num_drives) * sizeof(char *));
|
||||
} else {
|
||||
/* num_drives should be 0. Add assert? */
|
||||
*device_list = malloc((*num_drives) * sizeof(char *));
|
||||
}
|
||||
|
||||
(*device_list)[*num_drives-1] = strdup(drive);
|
||||
}
|
||||
} else {
|
||||
(*num_drives)++;
|
||||
*device_list = realloc(*device_list, (*num_drives) * sizeof(char *));
|
||||
if (*device_list) {
|
||||
*device_list = realloc(*device_list, (*num_drives) * sizeof(char *));
|
||||
} else {
|
||||
*device_list = malloc((*num_drives) * sizeof(char *));
|
||||
}
|
||||
(*device_list)[*num_drives-1] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user