libplctag / libplctag.NET

A .NET wrapper for libplctag.
https://libplctag.github.io/
Mozilla Public License 2.0
197 stars 49 forks source link

Provide overload for `GetBuffer(byte[] buffer)` #299

Closed timyhac closed 1 year ago

timyhac commented 1 year ago

The core library API for plc_tag_get_raw_bytes allows the caller to provide their own buffer for the method to fill.

Expose an overload of GetBuffer() that mirrors this behaviour. This will allow the caller to manage to lifetime of that memory, and potentially re-use it when appropriate (preventing garbage collection).

The key use-case for this is when taking a hash of the buffer, and using it for change detection. In this situation you do not need to keep multiple copies of the buffer, and a single buffer could be re-used between calls.