Skip to content

Commit

Permalink
Fix missing free() in ML code (+etc tweaks)
Browse files Browse the repository at this point in the history
  • Loading branch information
petabyt committed Jan 31, 2024
1 parent 687bf2f commit a644c52
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/bind.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 0 additions & 9 deletions src/camlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion src/ml.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a644c52

Please sign in to comment.