From 728f6f9e7f0a99aa584e7f35ade387e852b5fa83 Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Wed, 7 Mar 2018 22:41:10 -0700 Subject: Added a check at init that makes sure the user agrees with what FLT is --- include/libsurvive/survive.h | 10 +++++++++- src/survive.c | 9 ++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/libsurvive/survive.h b/include/libsurvive/survive.h index 30f5817..d9b5f08 100644 --- a/include/libsurvive/survive.h +++ b/include/libsurvive/survive.h @@ -156,7 +156,15 @@ struct SurviveContext }; -SurviveContext * survive_init( int headless ); +SurviveContext * survive_init_internal( int headless ); + +// Baked in size of FLT to verify users of the library have the correct setting. +void survive_verify_FLT_size(uint32_t user_size); + +static inline SurviveContext * survive_init( int headless ) { + survive_verify_FLT_size(sizeof(FLT)); + return survive_init_internal( headless ); +} //For any of these, you may pass in 0 for the function pointer to use default behavior. //In general unless you are doing wacky things like recording or playing back data, you won't need to use this. diff --git a/src/survive.c b/src/survive.c index 0386275..4e52637 100755 --- a/src/survive.c +++ b/src/survive.c @@ -94,7 +94,14 @@ static void *button_servicer(void * context) return NULL; } -SurviveContext * survive_init( int headless ) +void survive_verify_FLT_size(uint32_t user_size) { + if(sizeof(FLT) != user_size) { + fprintf(stderr, "FLT type incompatible; the shared library has FLT size %lu vs user program %u\n", sizeof(FLT), user_size); + exit(-1); + } +} + +SurviveContext * survive_init_internal( int headless ) { #ifdef RUNTIME_SYMNUM if( !did_runtime_symnum ) -- cgit v1.2.3