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

Update Tape.h issue #793 #1

Merged
merged 1 commit into from
Mar 21, 2024
Merged

Update Tape.h issue #793 #1

merged 1 commit into from
Mar 21, 2024

Conversation

Deepanshu9376
Copy link
Owner

updated the tape.h
Instead of ensuring contiguous elements, you suggest allocating slabs of 32 or 64 elements. Each slab would be a chunk of memory, and the last element in one slab would point to the next slab. This approach can improve memory management and reduce reallocation overhead.
You’ve defined an initial capacity of 32 elements (_init_capacity). If the tape is empty, this initial capacity is used. Otherwise, the capacity is doubled on each reallocation.
If memory allocation fails (!new_data), you clean up existing memory, print an error message, and abort execution.
Here’s an updated version of your grow() function incorporating these changes.

@Deepanshu9376 Deepanshu9376 merged commit 1242471 into master Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant