aboutsummaryrefslogtreecommitdiff
path: root/doc/language/function/cpsc-function-free.7.md
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-17 05:30:57 +0000
committer_ov4 <ov4@ov4.org>2026-10-17 05:30:57 +0000
commit4dd85fd6ecd9a67e5c2b68380873e6e114714355 (patch)
treeb9dad1d0845f4c2ae7e6efed171fbee40ccd1f31 /doc/language/function/cpsc-function-free.7.md
parente782898e420c7f2abd83b97c160194d0e70598dd (diff)
feat(memory): add tracked MALLOC and FREE builtins
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Diffstat (limited to 'doc/language/function/cpsc-function-free.7.md')
-rw-r--r--doc/language/function/cpsc-function-free.7.md32
1 files changed, 32 insertions, 0 deletions
diff --git a/doc/language/function/cpsc-function-free.7.md b/doc/language/function/cpsc-function-free.7.md
new file mode 100644
index 0000000..298199d
--- /dev/null
+++ b/doc/language/function/cpsc-function-free.7.md
@@ -0,0 +1,32 @@
+% CPSC-FUNCTION-FREE(7)
+
+# NAME
+
+cpsc-function-free - release an explicit memory allocation
+
+# SYNOPSIS
+
+```text
+FREE(pointer)
+```
+
+# DESCRIPTION
+
+FREE is a compiler extension. Its argument and return type are C void*. Explicitly cast other pointer types to a void* alias before passing them. A null pointer is accepted and returned. A non-null pointer must be the start of an active explicit MALLOC allocation; internal STRING/ARRAY storage, stack addresses, interior addresses and already released allocations are rejected with a source-line diagnostic on stdout and an anonymous exception.
+
+FREE returns its input address after releasing the allocation. It does not clear the caller's variable. The returned address and all aliases are invalid for memory access. Calling FREE again on that address throws unless a subsequent allocation has reused the address. Tracking cannot distinguish stale aliases once an address is reused.
+
+The result can be discarded with a standalone call. No user destructor is called.
+
+# EXAMPLE
+
+```text
+TYPE Raw = C_TYPE("void*")
+DECLARE Memory : Raw
+Memory <- MALLOC(8)
+FREE(Memory)
+```
+
+# SEE ALSO
+
+[cpsc-function-malloc(7)](cpsc-function-malloc.7.md), [cpsc-keyword-function(7)](../keyword/cpsc-keyword-function.7.md), [cpsc-keyword-try(7)](../keyword/cpsc-keyword-try.7.md).