Skip to content

Commit 3ad72bb

Browse files
authored
Merge pull request #80 from arik-so/2022-10-string-freeing-fix
Don't free strings for instance property accessors
2 parents 16dbd37 + bfac342 commit 3ad72bb

File tree

153 files changed

+679
-446
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+679
-446
lines changed

ci/LDKSwift/Sources/LDKSwift/bindings/Bindings.swift

Lines changed: 259 additions & 192 deletions
Large diffs are not rendered by default.

ci/LDKSwift/Sources/LDKSwift/bindings/options/APIError.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ APIError_clone(origPointer)
178178

179179

180180
public func getErr() -> String {
181-
return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err)
181+
return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err, callerContext: "APIError::APIMisuseError::getErr", deallocate: false)
182182
}
183183

184184

@@ -203,7 +203,7 @@ APIError_clone(origPointer)
203203

204204

205205
public func getErr() -> String {
206-
return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err)
206+
return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err, callerContext: "APIError::FeeRateTooHigh::getErr", deallocate: false)
207207
}
208208

209209
public func getFeerate() -> UInt32 {
@@ -232,7 +232,7 @@ APIError_clone(origPointer)
232232

233233

234234
public func getErr() -> String {
235-
return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err)
235+
return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err, callerContext: "APIError::RouteError::getErr", deallocate: false)
236236
}
237237

238238

@@ -257,7 +257,7 @@ APIError_clone(origPointer)
257257

258258

259259
public func getErr() -> String {
260-
return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err)
260+
return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err, callerContext: "APIError::ChannelUnavailable::getErr", deallocate: false)
261261
}
262262

263263

ci/LDKSwift/Sources/LDKSwift/bindings/options/ClosureReason.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ ClosureReason_clone(origPointer)
143143

144144
return Bindings.LDKCVec_u8Z_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (objPointer: UnsafePointer<LDKClosureReason>) in
145145
ClosureReason_write(objPointer)
146-
});
146+
}, callerContext: "ClosureReason::write");
147147
}
148148

149149
public class func read(ser: [UInt8]) -> Result_COption_ClosureReasonZDecodeErrorZ {
@@ -178,7 +178,7 @@ ClosureReason_write(objPointer)
178178

179179

180180
public func getPeer_msg() -> String {
181-
return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.peer_msg)
181+
return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.peer_msg, callerContext: "ClosureReason::CounterpartyForceClosed::getPeer_msg", deallocate: false)
182182
}
183183

184184

@@ -203,7 +203,7 @@ ClosureReason_write(objPointer)
203203

204204

205205
public func getErr() -> String {
206-
return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err)
206+
return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err, callerContext: "ClosureReason::ProcessingError::getErr", deallocate: false)
207207
}
208208

209209

ci/LDKSwift/Sources/LDKSwift/bindings/options/Event.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ Event_clone(origPointer)
369369

370370
return Bindings.LDKCVec_u8Z_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (objPointer: UnsafePointer<LDKEvent>) in
371371
Event_write(objPointer)
372-
});
372+
}, callerContext: "Event::write");
373373
}
374374

375375
public class func read(ser: [UInt8]) -> Result_COption_EventZDecodeErrorZ {
@@ -416,7 +416,7 @@ Event_write(objPointer)
416416
}
417417

418418
public func getOutput_script() -> [UInt8] {
419-
return Bindings.LDKCVec_u8Z_to_array(nativeType: self.cOpaqueStruct!.output_script, deallocate: false)
419+
return Bindings.LDKCVec_u8Z_to_array(nativeType: self.cOpaqueStruct!.output_script, callerContext: "Event::FundingGenerationReady::getOutput_script", deallocate: false)
420420
}
421421

422422
public func getUser_channel_id() -> UInt64 {
@@ -585,7 +585,7 @@ Event_write(objPointer)
585585
}
586586

587587
public func getPath() -> [RouteHop] {
588-
return Bindings.LDKCVec_RouteHopZ_to_array(nativeType: self.cOpaqueStruct!.path, deallocate: false)
588+
return Bindings.LDKCVec_RouteHopZ_to_array(nativeType: self.cOpaqueStruct!.path, callerContext: "Event::PaymentPathSuccessful::getPath", deallocate: false)
589589

590590
.map { (cOpaqueStruct) in
591591
RouteHop(pointer: cOpaqueStruct).dangle()
@@ -635,7 +635,7 @@ Event_write(objPointer)
635635
}
636636

637637
public func getPath() -> [RouteHop] {
638-
return Bindings.LDKCVec_RouteHopZ_to_array(nativeType: self.cOpaqueStruct!.path, deallocate: false)
638+
return Bindings.LDKCVec_RouteHopZ_to_array(nativeType: self.cOpaqueStruct!.path, callerContext: "Event::PaymentPathFailed::getPath", deallocate: false)
639639

640640
.map { (cOpaqueStruct) in
641641
RouteHop(pointer: cOpaqueStruct).dangle()
@@ -681,7 +681,7 @@ Event_write(objPointer)
681681
}
682682

683683
public func getPath() -> [RouteHop] {
684-
return Bindings.LDKCVec_RouteHopZ_to_array(nativeType: self.cOpaqueStruct!.path, deallocate: false)
684+
return Bindings.LDKCVec_RouteHopZ_to_array(nativeType: self.cOpaqueStruct!.path, callerContext: "Event::ProbeSuccessful::getPath", deallocate: false)
685685

686686
.map { (cOpaqueStruct) in
687687
RouteHop(pointer: cOpaqueStruct).dangle()
@@ -719,7 +719,7 @@ Event_write(objPointer)
719719
}
720720

721721
public func getPath() -> [RouteHop] {
722-
return Bindings.LDKCVec_RouteHopZ_to_array(nativeType: self.cOpaqueStruct!.path, deallocate: false)
722+
return Bindings.LDKCVec_RouteHopZ_to_array(nativeType: self.cOpaqueStruct!.path, callerContext: "Event::ProbeFailed::getPath", deallocate: false)
723723

724724
.map { (cOpaqueStruct) in
725725
RouteHop(pointer: cOpaqueStruct).dangle()
@@ -778,7 +778,7 @@ Event_write(objPointer)
778778

779779

780780
public func getOutputs() -> [SpendableOutputDescriptor] {
781-
return Bindings.LDKCVec_SpendableOutputDescriptorZ_to_array(nativeType: self.cOpaqueStruct!.outputs, deallocate: false)
781+
return Bindings.LDKCVec_SpendableOutputDescriptorZ_to_array(nativeType: self.cOpaqueStruct!.outputs, callerContext: "Event::SpendableOutputs::getOutputs", deallocate: false)
782782

783783
.map { (cOpaqueStruct) in
784784
SpendableOutputDescriptor(pointer: cOpaqueStruct).dangle()
@@ -882,7 +882,7 @@ Event_write(objPointer)
882882
}
883883

884884
public func getTransaction() -> [UInt8] {
885-
return Bindings.LDKTransaction_to_array(nativeType: self.cOpaqueStruct!.transaction, deallocate: false)
885+
return Bindings.LDKTransaction_to_array(nativeType: self.cOpaqueStruct!.transaction, callerContext: "Event::DiscardFunding::getTransaction", deallocate: false)
886886
}
887887

888888

ci/LDKSwift/Sources/LDKSwift/bindings/options/Fallback.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Fallback_eq(aPointer, bPointer)
170170
}
171171

172172
public func getProgram() -> [UInt8] {
173-
return Bindings.LDKCVec_u8Z_to_array(nativeType: self.cOpaqueStruct!.program, deallocate: false)
173+
return Bindings.LDKCVec_u8Z_to_array(nativeType: self.cOpaqueStruct!.program, callerContext: "Fallback::SegWitProgram::getProgram", deallocate: false)
174174
}
175175

176176

ci/LDKSwift/Sources/LDKSwift/bindings/options/HTLCDestination.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ HTLCDestination_clone(origPointer)
127127

128128
return Bindings.LDKCVec_u8Z_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (objPointer: UnsafePointer<LDKHTLCDestination>) in
129129
HTLCDestination_write(objPointer)
130-
});
130+
}, callerContext: "HTLCDestination::write");
131131
}
132132

133133
public class func read(ser: [UInt8]) -> Result_COption_HTLCDestinationZDecodeErrorZ {

ci/LDKSwift/Sources/LDKSwift/bindings/options/MonitorEvent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ MonitorEvent_clone(origPointer)
159159

160160
return Bindings.LDKCVec_u8Z_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (objPointer: UnsafePointer<LDKMonitorEvent>) in
161161
MonitorEvent_write(objPointer)
162-
});
162+
}, callerContext: "MonitorEvent::write");
163163
}
164164

165165
public class func read(ser: [UInt8]) -> Result_COption_MonitorEventZDecodeErrorZ {

ci/LDKSwift/Sources/LDKSwift/bindings/options/NetAddress.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ NetAddress_clone(origPointer)
155155

156156
return Bindings.LDKCVec_u8Z_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (objPointer: UnsafePointer<LDKNetAddress>) in
157157
NetAddress_write(objPointer)
158-
});
158+
}, callerContext: "NetAddress::write");
159159
}
160160

161161
public class func read(ser: [UInt8]) -> Result_NetAddressDecodeErrorZ {

ci/LDKSwift/Sources/LDKSwift/bindings/options/NetworkUpdate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ NetworkUpdate_clone(origPointer)
127127

128128
return Bindings.LDKCVec_u8Z_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (objPointer: UnsafePointer<LDKNetworkUpdate>) in
129129
NetworkUpdate_write(objPointer)
130-
});
130+
}, callerContext: "NetworkUpdate::write");
131131
}
132132

133133
public class func read(ser: [UInt8]) -> Result_COption_NetworkUpdateZDecodeErrorZ {

ci/LDKSwift/Sources/LDKSwift/bindings/options/Option_CVec_NetAddressZZ.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ extension Bindings {
6767
return nil
6868
}
6969
if self.cOpaqueStruct!.tag == LDKCOption_CVec_NetAddressZZ_Some {
70-
return Bindings.LDKCVec_NetAddressZ_to_array(nativeType: self.cOpaqueStruct!.some, deallocate: false)
70+
return Bindings.LDKCVec_NetAddressZ_to_array(nativeType: self.cOpaqueStruct!.some, callerContext: "Option_CVec_NetAddressZZ::getValue", deallocate: false)
7171

7272
.map { (cOpaqueStruct) in
7373
NetAddress(pointer: cOpaqueStruct).dangle()

0 commit comments

Comments
 (0)