@@ -95,7 +95,7 @@ All of the Rust-Lightning types are mapped into C equivalents which take a few f
95
95
```
96
96
97
97
* Various containers (Tuples, Vecs, Results, etc) are mapped into C structs of the form
98
- LDKCContainerType_ContainerElementsZ. Inner fields are often pointers, and in the case of
98
+ ` LDKCContainerType_ContainerElementsZ ` . Inner fields are often pointers, and in the case of
99
99
primitive types, these may be allocated in C using the system allocator. See [ the Rust docs on
100
100
your platform's default System allocator] ( https://doc.rust-lang.org/std/alloc/struct.System.html )
101
101
for which allocator you must use.
@@ -126,19 +126,18 @@ C++-isms to make memory model correctness easier to achieve. They provide:
126
126
In general, you should prefer to use the C++ bindings if possible, as they make memory leaks and
127
127
other violations somewhat easier to avoid. Note that, because the C functions are not redefined in
128
128
C++, all functions return the C type. Thus, you must bind returned values to the equivalent C++ type
129
- (replacing LDKX with LDK::X) to ensure the destructor is properly run. A demonstration of such usage
130
- is available at [ demo.cpp] ( demo.cpp ) .
129
+ (replacing ` LDKX ` with ` LDK::X ` ) to ensure the destructor is properly run. A demonstration of such
130
+ usage is available at [ demo.cpp] ( demo.cpp ) .
131
131
132
132
Gotchas
133
133
=======
134
134
135
135
There are a few gotchas around future changes to Rust-Lightning which the bindings may not support.
136
136
These include:
137
137
* Any trait method which returns a reference to a struct or inner variable cannot be called in
138
- parallel. This is due to the fact that such functions are mapped into a function which is called
139
- to get the return value, but then the return value is stored locally in the trait and a
140
- reference to that copy is returned. Such functions have comments describing the potential race
141
- conditions.
138
+ parallel. This is because such functions always return a local variable stored inside the trait,
139
+ with a call through a function pointer to get the local variable set correctly. Such functions
140
+ have comments describing the potential race conditions.
142
141
143
142
** It is highly recommended that you test any code which relies on the C (or C++) bindings in
144
143
valgrind, MemorySanitizer, or other similar tools to ensure correctness.**
0 commit comments