Skip to content

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

Description

@Bnaya

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions