-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfree_stack.c
More file actions
31 lines (27 loc) · 1.27 KB
/
free_stack.c
File metadata and controls
31 lines (27 loc) · 1.27 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
30
31
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* free_stack.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mihykim <mihykim@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/03/12 01:21:06 by mihykim #+# #+# */
/* Updated: 2020/03/12 02:51:58 by mihykim ### ########.fr */
/* */
/* ************************************************************************** */
#include "stack.h"
/*
** - Remove all data that the given 'stack' has and free the 'stack->data'
** - The data should be freed by the given function 'free data'
*/
void free_stack(t_stack *stack, void (*free_data)(void *))
{
if (stack == 0 || free_data == 0)
return ;
stack_clear(stack, free_data);
free(stack->data);
free(stack);
}
/*
** line 25 : free(stack->data), instead of free(stack)
*/