Merge pull request #177 from redthing1/fix/context-getstate

fix opaque GetState (fixes #176)
This commit is contained in:
Haiping 2023-09-19 06:51:36 -05:00 committed by GitHub
commit 79fa74d59c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -210,9 +210,13 @@ namespace LLama
// Shrink to size
memory = Marshal.ReAllocHGlobal(memory, (nint)actualSize);
// Wrap memory in a state and return it
// Wrap memory in a "state"
var state = new State(memory);
// Set memory to zero, to prevent it being freed in finally block
memory = IntPtr.Zero;
return new State(memory);
return state;
}
finally
{