phochmann / ctable Goto Github PK
View Code? Open in Web Editor NEWC library to print nicely formatted tables
License: GNU General Public License v3.0
C library to print nicely formatted tables
License: GNU General Public License v3.0
The function malloc_row
in src/table.c
can return NULL
if memory allocation fails:
The functions append_row
and get_empty_table
call malloc_row
but do not check the return value for NULL
:
https://github.com/PhilippHochmann/ctable/blob/e9ac72d79177474be4b28f7584f2e5aefc5f6f2e/src/table.c#L69-L79
https://github.com/PhilippHochmann/ctable/blob/e9ac72d79177474be4b28f7584f2e5aefc5f6f2e/src/table.c#L110-L123
The README should mention that the code to generate the tables in the example images can be seen in tests/test_table.c
Even better would be showing example usage code in the README.md or a standalone example file.
The function void print_table(Table *table)
prints to stdout
.
stdout
is like any FILE pointer though.
Possible new function could be void fprint_table(FILE *stream, Table *table)
that does the same as print_table
but a different FILE pointer can be specified.
The naming mirrors the relationship of printf
and fprintf
where fprintf
is the same but allows any FILE pointer to be used.
The function vec_create
calls malloc
but does not check the return value for NULL
:
vec_create
is called by strbuilder_create
is called by add_cell_vfmt
which can pass the NULL
as the text
argument to add_cell_internal
where it is assigned to the text
member of a Cell
struct (last line below):
This seems to create a large separation between where the problem is created (NULL
returned from malloc
) and where the problem will be noticed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.