Currently, Arc’s standard library handles pointers (in UI, mixer, and net modules) by casting void* to uintptr_t and storing them as int64_t. This approach is unsafe, prone to memory leaks, and makes it difficult to track pointer validity or ownership.
Proposed Solution:
Implement a dedicated Pointer object to wrap these memory addresses.
typedef struct Pointer {
Object base;
void* ptr;
void (*cleanup)(void* ptr)
} Pointer;
Goals:
- Replace
int64_t handles in std libraries with the Pointer object.
- Restrict arithmetic: Prevent the Arc VM/interpreter from allowing pointer arithmetic (e.g.,
ptr = ptr + 99 must be a compile-time or runtime error).
- Add reference counting (available through
Object base) to avoid memory leaks.
Expected Outcome/Checklist:
Currently, Arc’s standard library handles pointers (in UI, mixer, and net modules) by casting
void*touintptr_tand storing them asint64_t. This approach is unsafe, prone to memory leaks, and makes it difficult to track pointer validity or ownership.Proposed Solution:
Implement a dedicated
Pointerobject to wrap these memory addresses.Goals:
int64_thandles instdlibraries with thePointerobject.ptr = ptr + 99must be a compile-time or runtime error).Object base) to avoid memory leaks.Expected Outcome/Checklist:
Pointerobject definition.Pointerobject.UIlibrary to usePointer.Mixerlibrary to usePointer.Netlibrary to usePointer.