-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmfa_utils.c
More file actions
36 lines (33 loc) · 1.34 KB
/
mfa_utils.c
File metadata and controls
36 lines (33 loc) · 1.34 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
32
33
34
35
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mfa_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abdsalah <abdsalah@student.42amman.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/02/06 18:13:54 by abdsalah #+# #+# */
/* Updated: 2026/02/06 18:23:20 by abdsalah ### ########.fr */
/* */
/* ************************************************************************** */
#include "mfa.h"
t_mfa *load_mfa(FILE *input)
{
t_mfa *mfa = malloc(sizeof(t_mfa));
if (mfa == NULL)
return (NULL);
// memory allocation for the whole size of the file
long file_size = getFileSize(input);
mfa->data = malloc(file_size);
mfa->size = file_size;
// read into mfa->data
fread(mfa->data, 1, file_size, input);
return (mfa);
}
void free_mfa(t_mfa *mfa)
{
if (mfa)
{
free(mfa->data);
free(mfa);
}
}