-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstack_clear.c
More file actions
29 lines (26 loc) · 1.22 KB
/
stack_clear.c
File metadata and controls
29 lines (26 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* stack_clear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mihykim <mihykim@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/03/12 01:15:14 by mihykim #+# #+# */
/* Updated: 2020/03/12 01:27:04 by mihykim ### ########.fr */
/* */
/* ************************************************************************** */
#include "stack.h"
/*
** - Remove all data that the given 'stack' has.
** - The data should be freed by the given function 'free data'
*/
void stack_clear(t_stack *stack, void (*free_data)(void *))
{
if (stack == 0 || free_data == 0)
return ;
while (stack->top_index > -1)
{
free_data((stack->data)[stack->top_index]);
stack->top_index--;
}
}