kopia lustrzana https://gitlab.com/sane-project/backends
Get rid of small memory leak when using 'scanimage -L'.
rodzic
86ee15cba9
commit
7e318fb164
|
|
@ -178,6 +178,13 @@ struct alias
|
||||||
char *newname;
|
char *newname;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* List of available devices, allocated by sane_get_devices, released
|
||||||
|
* by sane_exit()
|
||||||
|
*/
|
||||||
|
static const SANE_Device **devlist = NULL;
|
||||||
|
static int devlist_size = 0, devlist_len = 0;
|
||||||
|
|
||||||
static struct alias *first_alias;
|
static struct alias *first_alias;
|
||||||
static SANE_Auth_Callback auth_callback;
|
static SANE_Auth_Callback auth_callback;
|
||||||
static struct backend *first_backend;
|
static struct backend *first_backend;
|
||||||
|
|
@ -584,6 +591,18 @@ sane_exit (void)
|
||||||
free(alias->oldname);
|
free(alias->oldname);
|
||||||
free(alias);
|
free(alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (NULL != devlist)
|
||||||
|
{ /* Release memory allocated by sane_get_devices(). */
|
||||||
|
int i = 0;
|
||||||
|
while (devlist[i])
|
||||||
|
free(devlist[i++]);
|
||||||
|
free(devlist);
|
||||||
|
|
||||||
|
devlist = NULL;
|
||||||
|
devlist_size = 0;
|
||||||
|
devlist_len = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Note that a call to get_devices() implies that we'll have to load
|
/* Note that a call to get_devices() implies that we'll have to load
|
||||||
|
|
@ -594,8 +613,6 @@ sane_exit (void)
|
||||||
SANE_Status
|
SANE_Status
|
||||||
sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only)
|
sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only)
|
||||||
{
|
{
|
||||||
static int devlist_size = 0, devlist_len = 0;
|
|
||||||
static const SANE_Device **devlist;
|
|
||||||
const SANE_Device **be_list;
|
const SANE_Device **be_list;
|
||||||
struct backend *be;
|
struct backend *be;
|
||||||
SANE_Status status;
|
SANE_Status status;
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@
|
||||||
#include "sane/sanei_config.h"
|
#include "sane/sanei_config.h"
|
||||||
#define V4L_CONFIG_FILE "v4l.conf"
|
#define V4L_CONFIG_FILE "v4l.conf"
|
||||||
|
|
||||||
|
static const SANE_Device ** devlist = NULL;
|
||||||
static int num_devices;
|
static int num_devices;
|
||||||
static V4L_Device * first_dev;
|
static V4L_Device * first_dev;
|
||||||
static V4L_Scanner * first_handle;
|
static V4L_Scanner * first_handle;
|
||||||
|
|
@ -179,6 +180,9 @@ attach (const char *devname, V4L_Device **devp)
|
||||||
{
|
{
|
||||||
V4L_Device * q;
|
V4L_Device * q;
|
||||||
|
|
||||||
|
if (!devp)
|
||||||
|
return SANE_STATUS_INVAL;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
q = malloc (sizeof (*q));
|
q = malloc (sizeof (*q));
|
||||||
|
|
@ -199,12 +203,8 @@ attach (const char *devname, V4L_Device **devp)
|
||||||
first_dev = q;
|
first_dev = q;
|
||||||
|
|
||||||
|
|
||||||
if (devp)
|
*devp = q;
|
||||||
*devp = q;
|
|
||||||
return SANE_STATUS_GOOD;
|
return SANE_STATUS_GOOD;
|
||||||
|
|
||||||
free (q);
|
|
||||||
return SANE_STATUS_INVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -626,12 +626,17 @@ sane_exit (void)
|
||||||
free ((void *) dev->sane.name);
|
free ((void *) dev->sane.name);
|
||||||
free (dev);
|
free (dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (NULL != devlist)
|
||||||
|
{
|
||||||
|
free(devlist);
|
||||||
|
devlist = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SANE_Status
|
SANE_Status
|
||||||
sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only)
|
sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only)
|
||||||
{
|
{
|
||||||
static const SANE_Device ** devlist = 0;
|
|
||||||
V4L_Device *dev;
|
V4L_Device *dev;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
|
||||||
Ładowanie…
Reference in New Issue