Skip to content

Commit

Permalink
Restructure README a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
semitrivial committed Dec 29, 2016
1 parent 93246ca commit 273a97f
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,23 @@ Both the array and the strings in the array are `malloc`'d.

Extract a line of CSV from a file.

Other arguments:
int max_line_size: a maximum line size. Lines longer than this will
cause fread_csv_line to return NULL.
int *done: Pointer to an int. The int is set to `1` when the end of `fp`
is reached.
int *err: Pointer to an int where error codes will be written. The error
codes are defined in `csv.h`: `CSV_ERR_LONGLINE` and `CSV_ERR_NO_MEMORY`.

Warning: `fread_csv_line` is optimized for repeating until the file is
exhausted. It mutates/depends on file position (in the `fseek` sense), in an
unpredictable way.

Warning: `fread_csv_line` shouldn't be called on different files in parallel.
(Hopefully sometime in the future we'll add a proper `init` system to deal with
this).
`max_line_size`: Lines longer than this will cause `fread_csv_line` to return
`NULL`.

`done`: Pointer to an int. The int is set to `1` when the end of `fp` is
reached.

`err`: Pointer to an int. On error, an error code will be written to this int.
Error codes are defined in `csv.h`: `CSV_ERR_LONGLINE` and `CSV_ERR_NO_MEMORY`.

## Caveats

`fread_csv_line` is optimized for repeating until the file is exhausted. It
mutates/depends on file position (in the `fseek` sense), in an unpredictable
way.

`fread_csv_line` shouldn't be called on different files in parallel. (Hopefully
sometime in the future we'll add a proper `init` system to deal with this).

Calling `fread_csv_line` on `fp` after a previous call exhausted the file
(indicated by `*done`) is undefined behavior.
Expand Down

0 comments on commit 273a97f

Please sign in to comment.