Skip to content

Luis Martinez#71

Open
luiscmartinez wants to merge 12 commits intobloominstituteoftechnology:masterfrom
luiscmartinez:master
Open

Luis Martinez#71
luiscmartinez wants to merge 12 commits intobloominstituteoftechnology:masterfrom
luiscmartinez:master

Conversation

@luiscmartinez
Copy link
Copy Markdown

No description provided.

if (arr->elements != NULL)
{
free(arr->elements);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you'll want to loop over each element and free them one by one.

arrays/arrays.c Outdated
if (arr->count >= arr->capacity)
{
// resize_array(arr);
fprintf(stderr, "Index, out of range");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice error message. 👍

newArray->capacity = capacity;
newArray->count = 0;
// Allocate memory for elements
newArray->elements = calloc(capacity, sizeof(char *));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of calloc instead of malloc here.

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.

2 participants