Skip to content

Commit 58bab87

Browse files
committed
Fix negative tail
1 parent 64d979a commit 58bab87

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

include/dataframe.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#define WC(fd, str) write(fd, str, sizeof str - 1)
1818
#define IDX_OF(array, i, mem_s) (array + ((i) * (mem_s)))
19+
#define ABS(v) (((v) < (0)) ? -(v) : (v))
1920

2021
typedef enum {
2122
BOOL,

src/df_tail.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ dataframe_t *df_tail(dataframe_t *df, int nb_rows)
1616
dataframe_t *new_df;
1717
void ***copy_src_data = df->data;
1818

19-
if (!nb_rows)
20-
return NULL;
19+
nb_rows = ABS(nb_rows);
2120
new_df = malloc(sizeof(dataframe_t));
2221
if (new_df == NULL)
2322
return NULL;

0 commit comments

Comments
 (0)