From a644c52731fe723683bf0fd2d3dfa76af7cb971a Mon Sep 17 00:00:00 2001 From: Daniel C Date: Tue, 30 Jan 2024 22:58:12 -0500 Subject: [PATCH] Fix missing free() in ML code (+etc tweaks) --- Makefile | 2 +- src/bind.c | 8 ++++++++ src/camlib.h | 9 --------- src/ml.c | 4 +++- test/test.c | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index bf3da5d..b9ec1a1 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ libcamlib.dylib: $(FILES) $(CC) -shared $(FILES) -L/usr/local/lib -lusb-1.0 -o libcamlib.so endif -%.o: %.c src/*.h +%.o: %.c $(CC) -MMD -c $(CFLAGS) $< -o $@ -include src/*.d lua/*.d lua/lua-cjson/*.d diff --git a/src/bind.c b/src/bind.c index 2655fce..3a367de 100644 --- a/src/bind.c +++ b/src/bind.c @@ -19,6 +19,14 @@ #endif #endif +#ifndef CAMLIB_PLATFORM + #ifdef WIN32 + #define CAMLIB_PLATFORM "windows" + #else + #define CAMLIB_PLATFORM "linux" + #endif +#endif + // TODO: func to access these int bind_connected = 0; int bind_initialized = 0; diff --git a/src/camlib.h b/src/camlib.h index 03c6c16..f86b37a 100644 --- a/src/camlib.h +++ b/src/camlib.h @@ -27,15 +27,6 @@ void ptp_verbose_log(char *fmt, ...); void ptp_panic(char *fmt, ...); -// Optional, used by frontend in bindings -#ifndef CAMLIB_PLATFORM - #ifdef WIN32 - #define CAMLIB_PLATFORM "windows" - #else - #define CAMLIB_PLATFORM "linux" - #endif -#endif - // 4mb recommended default buffer size #define CAMLIB_DEFAULT_SIZE 8000000 diff --git a/src/ml.c b/src/ml.c index f2ef966..01ad314 100644 --- a/src/ml.c +++ b/src/ml.c @@ -159,7 +159,9 @@ int ptp_chdk_upload_file(struct PtpRuntime *r, char *input, char *dest) { return PTP_RUNTIME_ERR; } - return ptp_send_data(r, &cmd, data, size_all); + int rc = ptp_send_data(r, &cmd, data, size_all); + free(data); + return rc; } int ptp_chdk_get_version(struct PtpRuntime *r) { diff --git a/test/test.c b/test/test.c index 3ab1aba..aa334e0 100644 --- a/test/test.c +++ b/test/test.c @@ -236,7 +236,7 @@ int main() { rc = test_multithread(); printf("Return code: %d\n", rc); if (rc) return rc; -return 0; + rc = test_eos_t6(); printf("Return code: %d\n", rc); if (rc) return rc;