Closed clibequilibrium closed 1 year ago
Hello,
The motivation behind implementing IDisposable is to allow automatic disposure of CString when they are no longer used by flecs
For example:
using (var cname = (Runtime.CString)name) { ecs_query_desc_t queryDescription = new() { filter = new ecs_filter_desc_t { expr = cname }, }; return ecs_query_init(World.Handle, &queryDescription); } }
Will automatically free the allocated CString once you leave the scope of using.
It is simple to implement in CString via
public readonly unsafe struct CString : IEquatable<CString>, IDisposable
public void Dispose() { if(!IsNull) Marshal.FreeHGlobal(_pointer); }
Implemented in C2CS v5.3; https://github.com/bottlenoselabs/c2cs/commit/98f0cc592d493801c81f7118d2e3aa4574457b0c
Hello,
The motivation behind implementing IDisposable is to allow automatic disposure of CString when they are no longer used by flecs
For example:
Will automatically free the allocated CString once you leave the scope of using.
It is simple to implement in CString via