Skip to content

Commit bebb5cb

Browse files
committed
Move utils prototypes into a separated header file
1 parent 0d39eef commit bebb5cb

File tree

8 files changed

+31
-15
lines changed

8 files changed

+31
-15
lines changed

include/copy_data.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414
bool copy_columns_type(dataframe_t *dst, dataframe_t *src);
1515
bool copy_columns_name(dataframe_t *dst, dataframe_t *src);
1616
bool copy_data(dataframe_t *dst, dataframe_t *src, int nb_rows);
17+
bool copy_data_value(dataframe_t *dst, dataframe_t *src, int row);
1718
#endif

include/dataframe.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,4 @@ dataframe_t *df_sort(dataframe_t *df, char const *column,
6868
bool (*sort_func)(void *vl1, void *vl2));
6969
dataframe_shape_t df_shape(dataframe_t *df);
7070
void df_free(dataframe_t *df);
71-
72-
// Utils (will me moved to another header)
73-
char **my_str_to_word_array(const char *str, const char *separator);
74-
void my_free_array(char **array);
75-
void free_data(void ***data, int nb_columns, int nb_rows);
76-
void *my_memdup(const uint8_t *mem, size_t bytes);
77-
bool data_storage(dataframe_t *dataframe, char **file, const char *separator);
78-
void mini_qsort(void ***arr, size_t size, int col,
79-
bool compare(void *, void *));
80-
8171
#endif /* !DATAFRAME_H_ */

include/utils.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
** EPITECH PROJECT, 2025
3+
** __
4+
** File description:
5+
** _
6+
*/
7+
8+
#ifndef UTILS_H
9+
#define UTILS_H
10+
#include <stdbool.h>
11+
#include <stdint.h>
12+
13+
#include "dataframe.h"
14+
15+
char **my_str_to_word_array(const char *str, const char *separator);
16+
void my_free_array(char **array);
17+
void free_data(void ***data, int nb_columns, int nb_rows);
18+
void *my_memdup(const uint8_t *mem, size_t bytes);
19+
bool data_storage(dataframe_t *dataframe, char **file, const char *separator);
20+
void mini_qsort(void ***arr, size_t size, int col,
21+
bool compare(void *, void *));
22+
int get_col_idx(dataframe_t *df, char const *name);
23+
#endif

src/copy_data.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <string.h>
1010

1111
#include "dataframe.h"
12+
#include "utils.h"
1213

1314
__attribute__((nonnull))
1415
bool copy_columns_type(dataframe_t *dst, dataframe_t *src)
@@ -35,7 +36,6 @@ bool copy_columns_name(dataframe_t *dst, dataframe_t *src)
3536
return true;
3637
}
3738

38-
static
3939
bool copy_data_value(dataframe_t *dst, dataframe_t *src, int row)
4040
{
4141
size_t sz;

src/df_read.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <unistd.h>
1515

1616
#include "dataframe.h"
17-
#include "debug.h"
17+
#include "utils.h"
1818

1919
static
2020
int get_nb_columns(char **file, const char *separator)

src/df_sort.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
#include "dataframe.h"
1212
#include "copy_data.h"
13+
#include "utils.h"
1314

14-
static
1515
int get_col_idx(dataframe_t *df, char const *name)
1616
{
1717
int i = 0;

src/store_data.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <string.h>
1515

1616
#include "dataframe.h"
17+
#include "utils.h"
1718

1819
static
1920
void check_is_string_or_bool(dataframe_t *df, int index_rows, int

tests/main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void print_df(int rows, int col, void ***data, column_type_t type)
4242
int main(int ac, char **av)
4343
{
4444
dataframe_t *src = df_read_csv(av[1], ";");
45-
dataframe_t *df = df_tail(src, 100);
45+
dataframe_t *df = df_tail(src, -10);
4646

4747
df_write_csv(df, "result.csv");
4848
if (df == NULL)
@@ -61,6 +61,7 @@ int main(int ac, char **av)
6161
print_df(rows, columns, df->data, df->column_type[columns]);
6262
puts("");
6363
}
64-
free(df);
64+
df_free(src);
65+
df_free(df);
6566
return 0;
6667
}

0 commit comments

Comments
 (0)