rgamble / libcsv

Fast and flexible CSV library written in pure ANSI C that can read and write CSV data.
GNU Lesser General Public License v2.1
181 stars 40 forks source link

Remove unused malloc_func element of struct csv_parser? #18

Closed jleffler closed 3 years ago

jleffler commented 4 years ago

Unless I've missed something, it would be possible (and trivial) to remove the malloc_func element of struct csv_parser. Apart from documentation, only the csv.h header and the libcsv.c file would be changed. The header would lose the line for malloc_func. The csv_init() function would lose the line that sets the element to a null pointer.

bobhairgrove commented 4 years ago

Looks like this member is never used anywhere else. Removing it would change the size of the struct csv_parser, though, and perhaps break existing code if using libcsv as a pre-built library. If used strictly as a source-code library, then removing it shouldn't break anything.

(EDIT: Don't know what I was thinking concerning removing the realloc_func ... obviously, the user can set this after calling csv_init() to a different function.)

rgamble commented 4 years ago

Thanks @jleffler for pointing out the unused malloc_func member. I think this is probably a holdover from before realloc_func was used for all allocations. Since removing this member would break ABI-compatibility with the current version (as @bobhairgrove noted) I would be hesitant to make that change in 3.x. If the next release does not introduce another ABI-breaking change we can certainly add a note indicating that this member is not used until it is removed.