@@ -184,11 +184,11 @@ private static partial byte proc_handler_call_native(
184184 #region Memory (for calldata management)
185185
186186 /// <summary>
187- /// Allocates zeroed memory using OBS's allocator.
187+ /// Allocates memory using OBS's allocator.
188188 /// </summary>
189- [ LibraryImport ( Lib , EntryPoint = "bzalloc " ) ]
189+ [ LibraryImport ( Lib , EntryPoint = "bmalloc " ) ]
190190 [ UnmanagedCallConv ( CallConvs = [ typeof ( CallConvCdecl ) ] ) ]
191- internal static partial nint bzalloc ( nuint size ) ;
191+ internal static partial nint bmalloc ( nuint size ) ;
192192
193193 /// <summary>
194194 /// Frees memory allocated by OBS's allocator.
@@ -211,8 +211,15 @@ private static partial byte proc_handler_call_native(
211211 /// </summary>
212212 internal static nint calldata_create ( )
213213 {
214- var cd = bzalloc ( CalldataSize ) ;
215- // bzalloc already zeros the memory, which is equivalent to calldata_init
214+ var cd = bmalloc ( CalldataSize ) ;
215+ if ( cd != nint . Zero )
216+ {
217+ // Zero the memory (equivalent to bzalloc/calldata_init)
218+ unsafe
219+ {
220+ new Span < byte > ( ( void * ) cd , ( int ) CalldataSize ) . Clear ( ) ;
221+ }
222+ }
216223 return cd ;
217224 }
218225
@@ -228,7 +235,6 @@ internal static void calldata_destroy(nint calldata)
228235 {
229236 var stackPtr = * ( nint * ) calldata ;
230237 // Check if not fixed (4th field, which is a bool - need to check offset)
231- // For simplicity, we'll just free the stack pointer if it's non-zero
232238 // The 'fixed' flag is at offset: sizeof(nint) + sizeof(nuint) + sizeof(nuint)
233239 var fixedOffset = nint . Size + nint . Size + nint . Size ;
234240 var isFixed = * ( byte * ) ( calldata + fixedOffset ) != 0 ;
0 commit comments