From 3f6b29ca999bc27bd09f2053759e7a3c4f02de24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sat, 4 Jun 2011 08:07:46 +0200 Subject: add k8055_alloc and k8055_free --- libk8055/k8055.h | 3 +++ libk8055/libk8055.c | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/libk8055/k8055.h b/libk8055/k8055.h index 69defbd..c28d4ec 100644 --- a/libk8055/k8055.h +++ b/libk8055/k8055.h @@ -42,6 +42,9 @@ extern "C" { unsigned char data_in[PACKET_LEN+1]; unsigned char data_out[PACKET_LEN+1]; }; + struct k8055_dev* k8055_alloc( void ); + void k8055_free( struct k8055_dev* dev ); + int k8055_read( struct k8055_dev* dev ); int k8055_write( struct k8055_dev* dev ); diff --git a/libk8055/libk8055.c b/libk8055/libk8055.c index 00aab65..85ee4a3 100644 --- a/libk8055/libk8055.c +++ b/libk8055/libk8055.c @@ -79,8 +79,9 @@ **/ -#include +#include #include +#include #include #include #include @@ -110,6 +111,16 @@ /* set debug to 0 to not print excess info */ static int debug = 0; +struct k8055_dev* k8055_alloc( void ) { + struct k8055_dev *dev = (struct k8055_dev*) malloc( sizeof(struct k8055_dev) ); + dev->dev_no=0; + return dev; +} + +void k8055_free( struct k8055_dev* dev ) { + free(dev); +} + /* Actual read of data from the device endpoint, retry READ_RETRY times if not responding ok */ int k8055_read( struct k8055_dev* dev ) { if( dev->dev_no==0 ) return K8055_ERROR; -- cgit v1.1-2-g2b99