Was destroying device list when getting capabilities. This should be an

in parameter only.
This commit is contained in:
rocky
2005-03-06 22:04:07 +00:00
parent 869bbacd94
commit 083e586379
2 changed files with 17 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
/* -*- c -*- /* -*- c -*-
$Id: device.h,v 1.19 2005/03/06 11:21:52 rocky Exp $ $Id: device.h,v 1.20 2005/03/06 22:04:07 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
@@ -289,7 +289,7 @@ extern "C" {
after dereferencing the the value is NULL. This also means nothing after dereferencing the the value is NULL. This also means nothing
was found. was found.
*/ */
char ** cdio_get_devices_with_cap (char* ppsz_search_devices[], char ** cdio_get_devices_with_cap (/*in*/ char *ppsz_search_devices[],
cdio_fs_anal_t capabilities, bool b_any); cdio_fs_anal_t capabilities, bool b_any);
/*! /*!
@@ -298,7 +298,7 @@ extern "C" {
and then *open* it afterwards. Giving the driver back facilitates this, and then *open* it afterwards. Giving the driver back facilitates this,
and speeds things up for libcdio as well. and speeds things up for libcdio as well.
*/ */
char ** cdio_get_devices_with_cap_ret (/*out*/ char* ppsz_search_devices[], char ** cdio_get_devices_with_cap_ret (/*in*/ char* ppsz_search_devices[],
cdio_fs_anal_t capabilities, cdio_fs_anal_t capabilities,
bool b_any, bool b_any,
/*out*/ driver_id_t *p_driver_id); /*out*/ driver_id_t *p_driver_id);

View File

@@ -1,5 +1,5 @@
/* /*
$Id: device.c,v 1.13 2005/03/06 11:21:52 rocky Exp $ $Id: device.c,v 1.14 2005/03/06 22:04:07 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
@@ -435,7 +435,7 @@ cdio_get_devices_ret (/*in/out*/ driver_id_t *p_driver_id)
the value is NULL. This also means nothing was found. the value is NULL. This also means nothing was found.
*/ */
char ** char **
cdio_get_devices_with_cap (/*out*/ char* search_devices[], cdio_get_devices_with_cap (/*in*/ char* search_devices[],
cdio_fs_anal_t capabilities, bool any) cdio_fs_anal_t capabilities, bool any)
{ {
driver_id_t p_driver_id; driver_id_t p_driver_id;
@@ -444,18 +444,23 @@ cdio_get_devices_with_cap (/*out*/ char* search_devices[],
} }
char ** char **
cdio_get_devices_with_cap_ret (/*out*/ char* search_devices[], cdio_get_devices_with_cap_ret (/*in*/ char* search_devices[],
cdio_fs_anal_t capabilities, bool any, cdio_fs_anal_t capabilities, bool any,
/*out*/ driver_id_t *p_driver_id) /*out*/ driver_id_t *p_driver_id)
{ {
char **ppsz_drives=search_devices; char **ppsz_drives=search_devices;
char **ppsz_drives_ret=NULL; char **ppsz_drives_ret=NULL;
unsigned int i_drives=0; unsigned int i_drives=0;
bool b_free_ppsz_drives = false;
*p_driver_id = DRIVER_DEVICE; *p_driver_id = DRIVER_DEVICE;
if (NULL == ppsz_drives) ppsz_drives=cdio_get_devices_ret(p_driver_id); if (!ppsz_drives) {
if (NULL == ppsz_drives) return NULL; ppsz_drives=cdio_get_devices_ret(p_driver_id);
b_free_ppsz_drives = true;
}
if (!ppsz_drives) return NULL;
if (capabilities == CDIO_FS_MATCH_ALL) { if (capabilities == CDIO_FS_MATCH_ALL) {
/* Duplicate drives into drives_ret. */ /* Duplicate drives into drives_ret. */
@@ -497,8 +502,10 @@ cdio_get_devices_with_cap_ret (/*out*/ char* search_devices[],
} }
} }
cdio_add_device_list(&ppsz_drives_ret, NULL, &i_drives); cdio_add_device_list(&ppsz_drives_ret, NULL, &i_drives);
if (b_free_ppsz_drives) {
cdio_free_device_list(ppsz_drives); cdio_free_device_list(ppsz_drives);
free(ppsz_drives); free(ppsz_drives);
}
return ppsz_drives_ret; return ppsz_drives_ret;
} }