CensoredUsername / dynasm-rs

A dynasm-like tool for rust.
https://censoredusername.github.io/dynasm-rs/language/index.html
Mozilla Public License 2.0
705 stars 52 forks source link

Improve documentation of `ExecutableBuffer::ptr`. #84

Open vext01 opened 10 months ago

vext01 commented 10 months ago

Presumably the underlying code buffer is dropped when the ExecutableBuffer is, so I think it would be a good idea to warn the user that when they obtain a raw pointer to the buffer, they are on their own WRT tracking the lifetime of the buffer?

Cheers

CensoredUsername commented 10 months ago

That is correct. Currently the documentation already mentions that this pointer is only valid if the lock on the Executor that provided the ExecutableBuffer is held, but since you can also get one directly by finalizing an assembler it's probably good to mention that.

But yes, when you get raw pointers you're always on your own WRT tracking that lifetime. The documentation does mention that the ExecutableBuffer holds ownership over the buffer so it deallocating on drop should be expected.

vext01 commented 10 months ago

since you can also get one directly by finalizing an assembler it's probably good to mention that

Exactly! That's how I was getting a buffer.

Thanks