Skip to content

Commit 72be89c

Browse files
committed
f readme - Tweaks Jeff suggested
1 parent 7d32f5b commit 72be89c

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lightning-c-bindings/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ All of the Rust-Lightning types are mapped into C equivalents which take a few f
9595
```
9696

9797
* 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
9999
primitive types, these may be allocated in C using the system allocator. See [the Rust docs on
100100
your platform's default System allocator](https://doc.rust-lang.org/std/alloc/struct.System.html)
101101
for which allocator you must use.
@@ -126,19 +126,18 @@ C++-isms to make memory model correctness easier to achieve. They provide:
126126
In general, you should prefer to use the C++ bindings if possible, as they make memory leaks and
127127
other violations somewhat easier to avoid. Note that, because the C functions are not redefined in
128128
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).
131131

132132
Gotchas
133133
=======
134134

135135
There are a few gotchas around future changes to Rust-Lightning which the bindings may not support.
136136
These include:
137137
* 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.
142141

143142
**It is highly recommended that you test any code which relies on the C (or C++) bindings in
144143
valgrind, MemorySanitizer, or other similar tools to ensure correctness.**

0 commit comments

Comments
 (0)