Merge pull request '[agent/codex:gpt-5.3-codex-spark] Read docs/RFC.md fully. Find ONE feature described in the sp...' (#13) from main into dev
This commit is contained in:
commit
00cbac5da2
2 changed files with 27 additions and 0 deletions
8
scope.go
8
scope.go
|
|
@ -80,3 +80,11 @@ func (s *Scope) FreeAll() {
|
|||
Free(pointer)
|
||||
}
|
||||
}
|
||||
|
||||
// IsFreed reports whether FreeAll has been called.
|
||||
func (s *Scope) IsFreed() bool {
|
||||
if s == nil {
|
||||
return true
|
||||
}
|
||||
return s.freed.Load()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,3 +37,22 @@ func TestScopePanicsAfterFreeAll(t *testing.T) {
|
|||
scope.CString("nope")
|
||||
})
|
||||
}
|
||||
|
||||
func TestScopeIsFreedTracksLifecycle(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
scope := NewScope()
|
||||
if scope.IsFreed() {
|
||||
t.Fatal("expected new scope to be active")
|
||||
}
|
||||
|
||||
scope.FreeAll()
|
||||
if !scope.IsFreed() {
|
||||
t.Fatal("expected scope to report freed after FreeAll")
|
||||
}
|
||||
|
||||
var nilScope *Scope
|
||||
if !nilScope.IsFreed() {
|
||||
t.Fatal("expected nil scope to be treated as freed")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue