free data structures on closing the camera.
updated TODO git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@9899 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
2007-01-18 Marcus Meissner <marcus@jet.franken.de>
|
||||
|
||||
* library.c, ptp.c, ptp-pack.c, ptp.h:
|
||||
Free datastructures on closing the camera.
|
||||
|
||||
2007-01-14 Marcus Meissner <marcus@jet.franken.de>
|
||||
|
||||
* usb.c: read in 64kb blobs again (512 bytes read are
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
|
||||
Unordered TODO list:
|
||||
|
||||
-- free() all malloced memory upon exit!
|
||||
|
||||
-- update params.handles and params.objectinfo structures after deletion of
|
||||
folders/files
|
||||
|
||||
-- lot of internal error handling code is needed and the whole internal
|
||||
error reporting scheme has to be reorganized and improved!
|
||||
|
||||
|
||||
@@ -1040,12 +1040,16 @@ static int
|
||||
camera_exit (Camera *camera, GPContext *context)
|
||||
{
|
||||
if (camera->pl!=NULL) {
|
||||
PTPParams *params = &camera->pl->params;
|
||||
/* close iconv converters */
|
||||
iconv_close(camera->pl->params.cd_ucs2_to_locale);
|
||||
iconv_close(camera->pl->params.cd_locale_to_ucs2);
|
||||
/* close ptp session */
|
||||
ptp_closesession (&camera->pl->params);
|
||||
free (camera->pl);
|
||||
ptp_closesession (params);
|
||||
ptp_free_params(params);
|
||||
free (params->data);
|
||||
free (camera->pl); /* also frees params */
|
||||
params = NULL;
|
||||
camera->pl = NULL;
|
||||
}
|
||||
if (camera->port!=NULL) {
|
||||
@@ -1057,10 +1061,6 @@ camera_exit (Camera *camera, GPContext *context)
|
||||
gp_port_usb_clear_halt
|
||||
(camera->port, GP_PORT_USB_ENDPOINT_INT);
|
||||
}
|
||||
|
||||
/* FIXME: free all camera->pl->params.objectinfo[] and
|
||||
other malloced data, like wifi profiles */
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
@@ -2289,23 +2289,29 @@ folder_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
|
||||
if (ptp_operation_issupported(params,PTP_OC_GetStorageIDs)) {
|
||||
CPR (context, ptp_getstorageids(params,
|
||||
&storageids));
|
||||
} else {
|
||||
storageids.n = 1;
|
||||
storageids.Storage[0]=0xdeadbeef;
|
||||
}
|
||||
for (i=0; i<storageids.n; i++) {
|
||||
char fname[PTP_MAXSTRLEN];
|
||||
for (i=0; i<storageids.n; i++) {
|
||||
char fname[PTP_MAXSTRLEN];
|
||||
|
||||
if ((storageids.Storage[i]&0x0000ffff)==0) continue;
|
||||
if ((storageids.Storage[i]&0x0000ffff)==0) continue;
|
||||
snprintf(fname, strlen(STORAGE_FOLDER_PREFIX)+9,
|
||||
STORAGE_FOLDER_PREFIX"%08x",
|
||||
storageids.Storage[i]);
|
||||
CR (gp_list_append (list, fname, NULL));
|
||||
}
|
||||
} else {
|
||||
char fname[PTP_MAXSTRLEN];
|
||||
snprintf(fname, strlen(STORAGE_FOLDER_PREFIX)+9,
|
||||
STORAGE_FOLDER_PREFIX"%08x",
|
||||
storageids.Storage[i]);
|
||||
CR (gp_list_append (list, fname, NULL));
|
||||
STORAGE_FOLDER_PREFIX"%08x",
|
||||
0xdeadbeef
|
||||
);
|
||||
gp_list_append (list, fname, NULL);
|
||||
}
|
||||
|
||||
if (nrofspecial_files)
|
||||
CR (gp_list_append (list, "special", NULL));
|
||||
|
||||
if (storageids.Storage[0] != 0xdeadbeef)
|
||||
free (storageids.Storage);
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
@@ -2641,6 +2647,7 @@ mtp_get_playlist_string(
|
||||
else
|
||||
free (content);
|
||||
*xcontentlen = contentlen;
|
||||
free (objects);
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -294,6 +294,20 @@ ptp_unpack_DI (PTPParams *params, unsigned char* data, PTPDeviceInfo *di, unsign
|
||||
PTP_di_OperationsSupported+totallen,
|
||||
&len);
|
||||
}
|
||||
|
||||
static void
|
||||
ptp_free_DI (PTPDeviceInfo *di) {
|
||||
if (di->SerialNumber) free (di->SerialNumber);
|
||||
if (di->DeviceVersion) free (di->DeviceVersion);
|
||||
if (di->Model) free (di->Model);
|
||||
if (di->Manufacturer) free (di->Manufacturer);
|
||||
if (di->ImageFormats) free (di->ImageFormats);
|
||||
if (di->CaptureFormats) free (di->CaptureFormats);
|
||||
if (di->VendorExtensionDesc) free (di->VendorExtensionDesc);
|
||||
if (di->OperationsSupported) free (di->OperationsSupported);
|
||||
if (di->EventsSupported) free (di->EventsSupported);
|
||||
if (di->DevicePropertiesSupported) free (di->DevicePropertiesSupported);
|
||||
}
|
||||
|
||||
/* ObjectHandles array pack/unpack */
|
||||
|
||||
|
||||
@@ -460,6 +460,33 @@ ptp_closesession (PTPParams* params)
|
||||
return ptp_transaction_new(params, &ptp, PTP_DP_NODATA, 0, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* ptp_free_params:
|
||||
* params: PTPParams*
|
||||
*
|
||||
* Frees all data within the PTPParams struct.
|
||||
*
|
||||
* Return values: Some PTP_RC_* code.
|
||||
**/
|
||||
void
|
||||
ptp_free_params (PTPParams *params) {
|
||||
while (params->proplist) {
|
||||
MTPPropList *xpl = params->proplist;
|
||||
|
||||
if ((xpl->datatype == PTP_DTC_STR) && (xpl->propval.str))
|
||||
free (xpl->propval.str);
|
||||
params->proplist = xpl->next;
|
||||
free (xpl);
|
||||
}
|
||||
if (params->canon_flags) free (params->canon_flags);
|
||||
if (params->cameraname) free (params->cameraname);
|
||||
if (params->wifi_profiles) free (params->wifi_profiles);
|
||||
free (params->handles.Handler);
|
||||
free (params->objectinfo);
|
||||
ptp_free_DI (¶ms->deviceinfo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ptp_getststorageids:
|
||||
* params: PTPParams*
|
||||
|
||||
@@ -1536,6 +1536,8 @@ int ptp_property_issupported (PTPParams* params, uint16_t property);
|
||||
void ptp_free_devicepropdesc (PTPDevicePropDesc* dpd);
|
||||
void ptp_free_devicepropvalue (uint16_t dt, PTPPropertyValue* dpd);
|
||||
void ptp_free_objectpropdesc (PTPObjectPropDesc* dpd);
|
||||
void ptp_free_params (PTPParams *params);
|
||||
|
||||
void ptp_perror (PTPParams* params, uint16_t error);
|
||||
|
||||
const char*
|
||||
|
||||
Reference in New Issue
Block a user