Skip to content

[Feature] Introduce Pointer object to replace int64_t handles #11

Description

@VxidDev

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:

  • Create Pointer object definition.
  • Add reference counting to Pointer object.
  • Update UI library to use Pointer.
  • Update Mixer library to use Pointer.
  • Update Net library to use Pointer.
  • Implement checks in the VM/compiler to block invalid pointer operations.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions