aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcnlohr <lohr85@gmail.com>2017-02-26 10:28:56 -0500
committercnlohr <lohr85@gmail.com>2017-02-26 10:28:56 -0500
commit51751d4a9f407f526de2b626d44e14690fbef004 (patch)
treeb7d81c89b3a4ccb72d46e5194929b47df88345b7 /src
parentf4ab8c084c1e23e850f436c2c0bb6777da3d942a (diff)
downloadlibsurvive-51751d4a9f407f526de2b626d44e14690fbef004.tar.gz
libsurvive-51751d4a9f407f526de2b626d44e14690fbef004.tar.bz2
cleanup
Diffstat (limited to 'src')
-rw-r--r--src/survive.c10
-rw-r--r--src/survive_driverman.c6
-rw-r--r--src/survive_driverman.h20
-rw-r--r--src/survive_internal.h4
4 files changed, 34 insertions, 6 deletions
diff --git a/src/survive.c b/src/survive.c
index 306dbe1..9bc1a2c 100644
--- a/src/survive.c
+++ b/src/survive.c
@@ -136,11 +136,15 @@ void survive_close( struct SurviveContext * ctx )
int i;
for( i = 0; i < oldct; i++ )
{
- ctx->driverpolls[i]( ctx, ctx->drivers[i] );
+ ctx->drivercloses[i]( ctx, ctx->drivers[i] );
}
- //TODO: Free everything except for self.
- //XXX Will leak memory.
+ free( ctx->objs );
+ free( ctx->drivers );
+ free( ctx->driverpolls );
+ free( ctx->drivermagics );
+ free( ctx->drivercloses );
+ free( ctx );
}
int survive_poll( struct SurviveContext * ctx )
diff --git a/src/survive_driverman.c b/src/survive_driverman.c
index b4684c8..8cdfb71 100644
--- a/src/survive_driverman.c
+++ b/src/survive_driverman.c
@@ -1,3 +1,8 @@
+// (C) 2017 <>< C. N. Lohr, Under MIT/x11 License.
+//
+// See notice in survive_driverman.h
+//
+
#include "survive_driverman.h"
#include <string.h>
#include <stdio.h>
@@ -45,6 +50,5 @@ void ListDrivers()
{
printf( " %s\n", DriverNames[i] );
}
-
}
diff --git a/src/survive_driverman.h b/src/survive_driverman.h
index fb385da..5e13caf 100644
--- a/src/survive_driverman.h
+++ b/src/survive_driverman.h
@@ -1,3 +1,12 @@
+// (C) 2017 <>< C. N. Lohr, Under MIT/x11 License.
+//
+// This file is intended to be used for self-registering functions. By using
+// this it means that you do not need to have complicated switch statements or
+// #defines for dfferent inclusion of drivers/other code. You can simply
+// register your function and it will be put into a list.
+//
+//
+
#ifndef SURVIVE_DRIVERMAN_H
#define SURVIVE_DRIVERMAN_H
@@ -12,11 +21,18 @@ void ListDrivers();
#define REGISTER_LINKTIME( func ) \
void __attribute__((constructor)) Register##func() { RegisterDriver( #func, &func ); }
+
+//
+// Specific types of drivers.
+//
+
struct SurviveContext;
+//Device drivers (prefix your drivers with "DriverReg") i.e.
+// REGISTER_LINKTIME( DriverRegHTCVive );
typedef int (*DeviceDriver)( struct SurviveContext * ctx );
-typedef int (*DeviceDriverCb)( struct SurviveContext * ctx, void * driver );
-typedef int (*DeviceDriverMagicCb)( struct SurviveContext * ctx, void * driver, int magic_code, void * data, int datalen );
+
+//more driver types here? i.e. posefinders, etc.
#endif
diff --git a/src/survive_internal.h b/src/survive_internal.h
index 3dc471a..5962623 100644
--- a/src/survive_internal.h
+++ b/src/survive_internal.h
@@ -33,6 +33,10 @@
struct SurviveContext;
struct SurviveUSBInterface;
+typedef int (*DeviceDriverCb)( struct SurviveContext * ctx, void * driver );
+typedef int (*DeviceDriverMagicCb)( struct SurviveContext * ctx, void * driver, int magic_code, void * data, int datalen );
+
+
//This is defined in survive.h
struct SurviveObject;
struct SurviveCalData;