Skip to content

Update chunk.c #1177

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update chunk.c
I think this is logically equivalent (it is what I use in my vector types) and saves a `+1`.
mark-summerfield authored Sep 24, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 3adc45d8a07be0abbc85fc0ec9b7610271b0bbf2
2 changes: 1 addition & 1 deletion c/chunk.c
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ void writeChunk(Chunk* chunk, uint8_t byte) {
//> write-chunk-with-line
void writeChunk(Chunk* chunk, uint8_t byte, int line) {
//< write-chunk-with-line
if (chunk->capacity < chunk->count + 1) {
if (chunk->capacity == chunk->count) {
int oldCapacity = chunk->capacity;
chunk->capacity = GROW_CAPACITY(oldCapacity);
chunk->code = GROW_ARRAY(uint8_t, chunk->code,