Skip to content
Closed
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
13 changes: 2 additions & 11 deletions data_structures/stack/stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,8 @@ void grow()
{
max += 10; /* increases the capacity */

int i; // for the loop
void **tmp = malloc(sizeof(void *) * max);

/* copies the elements from the origin array in the new one. */
for (i = 0; i < max - 10; i++)
{
*(tmp + i) = *(array + i);
}
/*free the memory */
free(array);
array = tmp;
array = (void **)realloc(array, sizeof(void *) * max);
assert(array); /* tests whether pointer is assigned to memory. */
}

/* push: pushs the argument onto the stack */
Expand Down