Remove more memory leaks caught by valgrind.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
$Id: sample5.c,v 1.4 2003/10/02 02:59:57 rocky Exp $
|
$Id: sample5.c,v 1.5 2004/03/20 22:46:56 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -23,8 +23,15 @@
|
|||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_STDIO_H
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STDLIB_H
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
#include <cdio/cdio.h>
|
#include <cdio/cdio.h>
|
||||||
#include <cdio/cd_types.h>
|
#include <cdio/cd_types.h>
|
||||||
#include <cdio/logging.h>
|
#include <cdio/logging.h>
|
||||||
@@ -56,6 +63,8 @@ main(int argc, const char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
cdio_free_device_list(cd_drives);
|
cdio_free_device_list(cd_drives);
|
||||||
|
free(cd_drives);
|
||||||
|
|
||||||
printf("-----\n");
|
printf("-----\n");
|
||||||
|
|
||||||
cd_drives = NULL;
|
cd_drives = NULL;
|
||||||
@@ -67,9 +76,9 @@ main(int argc, const char *argv[])
|
|||||||
printf("Drive %s\n", *c);
|
printf("Drive %s\n", *c);
|
||||||
}
|
}
|
||||||
|
|
||||||
cdio_free_device_list(cd_drives);
|
|
||||||
}
|
}
|
||||||
|
cdio_free_device_list(cd_drives);
|
||||||
|
free(cd_drives);
|
||||||
|
|
||||||
printf("-----\n");
|
printf("-----\n");
|
||||||
printf("CD-DA drives...\n");
|
printf("CD-DA drives...\n");
|
||||||
@@ -81,9 +90,9 @@ main(int argc, const char *argv[])
|
|||||||
for( c = cd_drives; *c != NULL; c++ ) {
|
for( c = cd_drives; *c != NULL; c++ ) {
|
||||||
printf("drive: %s\n", *c);
|
printf("drive: %s\n", *c);
|
||||||
}
|
}
|
||||||
|
|
||||||
cdio_free_device_list(cd_drives);
|
|
||||||
}
|
}
|
||||||
|
cdio_free_device_list(cd_drives);
|
||||||
|
free(cd_drives);
|
||||||
|
|
||||||
printf("-----\n");
|
printf("-----\n");
|
||||||
cd_drives = NULL;
|
cd_drives = NULL;
|
||||||
@@ -99,6 +108,8 @@ main(int argc, const char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
cdio_free_device_list(cd_drives);
|
cdio_free_device_list(cd_drives);
|
||||||
|
free(cd_drives);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* -*- c -*-
|
/* -*- c -*-
|
||||||
$Id: cdio.h,v 1.36 2004/03/06 18:30:44 rocky Exp $
|
$Id: cdio.h,v 1.37 2004/03/20 22:46:57 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
@@ -146,6 +146,8 @@ extern "C" {
|
|||||||
To find a CD-drive of any type, use the mask CDIO_FS_MATCH_ALL.
|
To find a CD-drive of any type, use the mask CDIO_FS_MATCH_ALL.
|
||||||
|
|
||||||
NULL is returned if we couldn't get a default device.
|
NULL is returned if we couldn't get a default device.
|
||||||
|
It is also possible to return a non NULL but after dereferencing the
|
||||||
|
the value is NULL. This also means nothing was found.
|
||||||
*/
|
*/
|
||||||
char ** cdio_get_devices_with_cap (char* search_devices[],
|
char ** cdio_get_devices_with_cap (char* search_devices[],
|
||||||
cdio_fs_anal_t capabilities, bool any);
|
cdio_fs_anal_t capabilities, bool any);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# $Id: Makefile.am,v 1.28 2004/03/20 04:12:07 rocky Exp $
|
# $Id: Makefile.am,v 1.29 2004/03/20 22:46:57 rocky Exp $
|
||||||
#
|
#
|
||||||
# Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
# Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
#
|
#
|
||||||
@@ -40,8 +40,8 @@
|
|||||||
# 6. If any interfaces have been removed since the last public release,
|
# 6. If any interfaces have been removed since the last public release,
|
||||||
# then set AGE to 0.
|
# then set AGE to 0.
|
||||||
|
|
||||||
libcdio_la_CURRENT := 0
|
libcdio_la_CURRENT := 1
|
||||||
libcdio_la_REVISION := 2
|
libcdio_la_REVISION := 0
|
||||||
libcdio_la_AGE := 0
|
libcdio_la_AGE := 0
|
||||||
|
|
||||||
libiso9660_la_CURRENT := 1
|
libiso9660_la_CURRENT := 1
|
||||||
|
|||||||
@@ -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) 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#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 <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -135,8 +135,6 @@ cdio_generic_stdio_free (void *user_data)
|
|||||||
|
|
||||||
if (_obj->data_source)
|
if (_obj->data_source)
|
||||||
cdio_stdio_destroy (_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) {
|
if (NULL != drive) {
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
|
|
||||||
|
/* Check if drive is already in list. */
|
||||||
for (j=0; j<*num_drives; j++) {
|
for (j=0; j<*num_drives; j++) {
|
||||||
if (strcmp((*device_list)[j], drive) == 0) break;
|
if (strcmp((*device_list)[j], drive) == 0) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j==*num_drives) {
|
if (j==*num_drives) {
|
||||||
|
/* Drive not in list. Add it. */
|
||||||
(*num_drives)++;
|
(*num_drives)++;
|
||||||
|
if (*device_list) {
|
||||||
*device_list = realloc(*device_list, (*num_drives) * sizeof(char *));
|
*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);
|
(*device_list)[*num_drives-1] = strdup(drive);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(*num_drives)++;
|
(*num_drives)++;
|
||||||
|
if (*device_list) {
|
||||||
*device_list = realloc(*device_list, (*num_drives) * sizeof(char *));
|
*device_list = realloc(*device_list, (*num_drives) * sizeof(char *));
|
||||||
|
} else {
|
||||||
|
*device_list = malloc((*num_drives) * sizeof(char *));
|
||||||
|
}
|
||||||
(*device_list)[*num_drives-1] = NULL;
|
(*device_list)[*num_drives-1] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
lib/cdio.c
12
lib/cdio.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: cdio.c,v 1.41 2004/03/10 10:57:44 rocky Exp $
|
$Id: cdio.c,v 1.42 2004/03/20 22:46:57 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
#include <cdio/logging.h>
|
#include <cdio/logging.h>
|
||||||
#include "cdio_private.h"
|
#include "cdio_private.h"
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: cdio.c,v 1.41 2004/03/10 10:57:44 rocky Exp $";
|
static const char _rcsid[] = "$Id: cdio.c,v 1.42 2004/03/20 22:46:57 rocky Exp $";
|
||||||
|
|
||||||
|
|
||||||
const char *track_format2str[6] =
|
const char *track_format2str[6] =
|
||||||
@@ -299,7 +299,9 @@ cdio_get_devices (driver_id_t driver_id)
|
|||||||
|
|
||||||
if (cdio == NULL) return NULL;
|
if (cdio == NULL) return NULL;
|
||||||
if (cdio->op.get_devices) {
|
if (cdio->op.get_devices) {
|
||||||
return cdio->op.get_devices ();
|
char **devices = cdio->op.get_devices ();
|
||||||
|
cdio_destroy(cdio);
|
||||||
|
return devices;
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -318,6 +320,8 @@ cdio_get_devices (driver_id_t driver_id)
|
|||||||
To find a CD-drive of any type, use the mask CDIO_FS_MATCH_ALL.
|
To find a CD-drive of any type, use the mask CDIO_FS_MATCH_ALL.
|
||||||
|
|
||||||
NULL is returned if we couldn't get a default device.
|
NULL is returned if we couldn't get a default device.
|
||||||
|
It is also possible to return a non NULL but after dereferencing the
|
||||||
|
the value is NULL. This also means nothing was found.
|
||||||
*/
|
*/
|
||||||
char **
|
char **
|
||||||
cdio_get_devices_with_cap (char* search_devices[],
|
cdio_get_devices_with_cap (char* search_devices[],
|
||||||
@@ -362,8 +366,8 @@ cdio_get_devices_with_cap (char* search_devices[],
|
|||||||
cdio_destroy(cdio);
|
cdio_destroy(cdio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cdio_add_device_list(&drives_ret, NULL, &num_drives);
|
|
||||||
}
|
}
|
||||||
|
cdio_add_device_list(&drives_ret, NULL, &num_drives);
|
||||||
return drives_ret;
|
return drives_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: bincue.c,v 1.7 2004/03/20 21:54:38 rocky Exp $
|
$Id: bincue.c,v 1.8 2004/03/20 22:46:57 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
(*.cue).
|
(*.cue).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: bincue.c,v 1.7 2004/03/20 21:54:38 rocky Exp $";
|
static const char _rcsid[] = "$Id: bincue.c,v 1.8 2004/03/20 22:46:57 rocky Exp $";
|
||||||
|
|
||||||
#include "cdio_assert.h"
|
#include "cdio_assert.h"
|
||||||
#include "cdio_private.h"
|
#include "cdio_private.h"
|
||||||
@@ -736,7 +736,7 @@ cdio_get_default_device_bincue(void)
|
|||||||
{
|
{
|
||||||
char **drives = cdio_get_devices_nrg();
|
char **drives = cdio_get_devices_nrg();
|
||||||
char *drive = (drives[0] == NULL) ? NULL : strdup(drives[0]);
|
char *drive = (drives[0] == NULL) ? NULL : strdup(drives[0]);
|
||||||
cdio_free_device_list(&drives);
|
cdio_free_device_list(drives);
|
||||||
return drive;
|
return drive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: nrg.c,v 1.3 2004/03/06 18:22:07 rocky Exp $
|
$Id: nrg.c,v 1.4 2004/03/20 22:46:57 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2001, 2003 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2001, 2003 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
#include "cdio_private.h"
|
#include "cdio_private.h"
|
||||||
#include "_cdio_stdio.h"
|
#include "_cdio_stdio.h"
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: nrg.c,v 1.3 2004/03/06 18:22:07 rocky Exp $";
|
static const char _rcsid[] = "$Id: nrg.c,v 1.4 2004/03/20 22:46:57 rocky Exp $";
|
||||||
|
|
||||||
/* structures used */
|
/* structures used */
|
||||||
|
|
||||||
@@ -998,6 +998,7 @@ _cdio_nrg_destroy (void *obj)
|
|||||||
if (NULL != env->mapping)
|
if (NULL != env->mapping)
|
||||||
_cdio_list_free (env->mapping, true);
|
_cdio_list_free (env->mapping, true);
|
||||||
cdio_generic_stdio_free(env);
|
cdio_generic_stdio_free(env);
|
||||||
|
free(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1215,6 +1216,7 @@ cdio_open_nrg (const char *source_name)
|
|||||||
return ret;
|
return ret;
|
||||||
else {
|
else {
|
||||||
cdio_generic_stdio_free (_data);
|
cdio_generic_stdio_free (_data);
|
||||||
|
free(_data);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: cd-info.c,v 1.49 2004/02/21 13:09:12 rocky Exp $
|
$Id: cd-info.c,v 1.50 2004/03/20 22:46:57 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org>
|
Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org>
|
||||||
@@ -840,6 +840,7 @@ main(int argc, const char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
cdio_free_device_list(device_list);
|
cdio_free_device_list(device_list);
|
||||||
|
free(device_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts.access_mode!=NULL) {
|
if (opts.access_mode!=NULL) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
$Id: testdefault.c,v 1.3 2003/10/03 01:33:15 rocky Exp $
|
$Id: testdefault.c,v 1.4 2004/03/20 22:46:57 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -123,6 +123,7 @@ main(int argc, const char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
cdio_free_device_list(imgs);
|
cdio_free_device_list(imgs);
|
||||||
|
free(imgs);
|
||||||
|
|
||||||
|
|
||||||
printf("-----\n");
|
printf("-----\n");
|
||||||
@@ -141,6 +142,7 @@ main(int argc, const char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
cdio_free_device_list(imgs);
|
cdio_free_device_list(imgs);
|
||||||
|
free(imgs);
|
||||||
|
|
||||||
|
|
||||||
printf("-----\n");
|
printf("-----\n");
|
||||||
@@ -160,6 +162,7 @@ main(int argc, const char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
cdio_free_device_list(imgs);
|
cdio_free_device_list(imgs);
|
||||||
|
free(imgs);
|
||||||
|
|
||||||
imgs = NULL;
|
imgs = NULL;
|
||||||
/* Print out a list of CDDA-drives. */
|
/* Print out a list of CDDA-drives. */
|
||||||
@@ -180,6 +183,7 @@ main(int argc, const char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
cdio_free_device_list(imgs);
|
cdio_free_device_list(imgs);
|
||||||
|
free(imgs);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user