From dee218a7eeeca61b103b63b24d71f17c5f95766f Mon Sep 17 00:00:00 2001 From: Daniel C Date: Mon, 2 Oct 2023 22:31:29 -0400 Subject: [PATCH] ptp_generic_reset will only reset specific connection info --- src/libusb.c | 2 ++ src/util.c | 7 ++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libusb.c b/src/libusb.c index f6bbab7..9e888dc 100644 --- a/src/libusb.c +++ b/src/libusb.c @@ -22,6 +22,8 @@ struct LibUSBBackend { }; int ptp_comm_init(struct PtpRuntime *r) { + ptp_generic_reset(r); + if (r->comm_backend != NULL) { ptp_verbose_log("ptp_comm_init() called with comm backend already allocated\n"); return 0; diff --git a/src/util.c b/src/util.c index e46fe47..92916ef 100644 --- a/src/util.c +++ b/src/util.c @@ -9,14 +9,9 @@ #include void ptp_generic_reset(struct PtpRuntime *r) { - memset(r, 0, sizeof(struct PtpRuntime)); - r->active_connection = 0; r->transaction = 0; r->session = 0; - r->max_packet_size = 512; - r->data_phase_length = 0; - r->di = NULL; r->connection_type = PTP_USB; r->caller_unlocks_mutex = 0; r->mutex = NULL; @@ -24,7 +19,9 @@ void ptp_generic_reset(struct PtpRuntime *r) { } void ptp_generic_init(struct PtpRuntime *r) { + memset(r, 0, sizeof(struct PtpRuntime)); ptp_generic_reset(r); + r->data = malloc(CAMLIB_DEFAULT_SIZE); r->data_length = CAMLIB_DEFAULT_SIZE;