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

Refactor linkedListItemInsert to return pointer to pointer, and not save value #101

Open
Bnaya opened this issue May 29, 2020 · 0 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@Bnaya
Copy link
Owner

Bnaya commented May 29, 2020

The linkedListItemInsert api accepts nodeValuePointer, and saves it.
A better api would be to simply return pointer to pointer and let the caller to do the actual write when he see fits

export function linkedListItemInsert(
carrier: GlobalCarrier,
linkedListPointer: number,
nodeValuePointer: number
) {
const { allocator, heap } = carrier;
const newEndMarker = allocator.calloc(linkedListItem_size);
linkedListItem_set_all(heap, newEndMarker, 0, 0);
const wasEndMarker = linkedList_END_POINTER_get(heap, linkedListPointer);
linkedList_END_POINTER_set(heap, linkedListPointer, newEndMarker);
linkedListItem_set_all(heap, wasEndMarker, newEndMarker, nodeValuePointer);
return wasEndMarker;
}

@Bnaya Bnaya added good first issue Good for newcomers help wanted Extra attention is needed labels May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant