mirror of
git://sigrok.org/libserialport
synced 2023-08-10 21:13:24 +03:00
Add sp_free_port() function.
This commit is contained in:
parent
77f262c4f9
commit
e3b2f7a4e3
13
serialport.c
13
serialport.c
@ -73,6 +73,17 @@ int sp_get_port_by_name(const char *portname, struct sp_port **port_ptr)
|
||||
return SP_OK;
|
||||
}
|
||||
|
||||
void sp_free_port(struct sp_port *port)
|
||||
{
|
||||
if (!port)
|
||||
return;
|
||||
|
||||
if (port->name)
|
||||
free(port->name);
|
||||
|
||||
free(port);
|
||||
}
|
||||
|
||||
static struct sp_port **sp_list_append(struct sp_port **list, const char *portname)
|
||||
{
|
||||
void *tmp;
|
||||
@ -313,7 +324,7 @@ void sp_free_port_list(struct sp_port **list)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; list[i]; i++)
|
||||
free(list[i]);
|
||||
sp_free_port(list[i]);
|
||||
free(list);
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,7 @@ enum {
|
||||
};
|
||||
|
||||
int sp_get_port_by_name(const char *portname, struct sp_port **port_ptr);
|
||||
void sp_free_port(struct sp_port *port);
|
||||
int sp_list_ports(struct sp_port ***list_ptr);
|
||||
void sp_free_port_list(struct sp_port **ports);
|
||||
int sp_open(struct sp_port *port, int flags);
|
||||
|
Loading…
Reference in New Issue
Block a user