Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve allocate API #323

Closed
eudoxia0 opened this issue Aug 20, 2022 · 0 comments · Fixed by #324
Closed

Improve allocate API #323

eudoxia0 opened this issue Aug 20, 2022 · 0 comments · Fixed by #324
Assignees
Labels
enhancement New feature or request

Comments

@eudoxia0
Copy link
Member

eudoxia0 commented Aug 20, 2022

The current API is too easy to misuse:

generic [T: Type]
function allocate(count: Index): Address[T];

To allocate a single object, the client should pass 1, but they might easily pass sizeof(T) instead, which allocates more memory.

We should break this up into:

generic [T: Type]
function allocate(): Address[T];

generic [T: Type]
function allocateBuffer(count: Index): Address[T];

This issue was pointed out in: #310

@eudoxia0 eudoxia0 added the enhancement New feature or request label Aug 20, 2022
@eudoxia0 eudoxia0 self-assigned this Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant