jwerle / asprintf.c Goto Github PK
View Code? Open in Web Editor NEWasprintf() implementation
License: MIT License
asprintf() implementation
License: MIT License
... may I create a 0.0.2 tag?
make install
will do nothing.
You may build a *.a
or *.so
lib instead.
mind if I add travis? config should be super simple:
language: c
script: make check
there's no need to set args = {{0}}
:
cc deps/asprintf/asprintf.c -c -o deps/asprintf/asprintf.o -std=c99 -Wall -Wextra -Ideps
deps/asprintf/asprintf.c:19:21: warning: missing field 'fp_offset' initializer [-Wmissing-field-initializers]
va_list args = {{0}};
^
deps/asprintf/asprintf.c:36:21: warning: missing field 'fp_offset' initializer [-Wmissing-field-initializers]
va_list tmpa = {{0}};
^
2 warnings generated.
asprintf
is available on both GNU and FreeBSD. Nowever, they
have slightly differently. You should document this functions
exact behaviour.
The line
size = vsnprintf(NULL, size, fmt, tmpa);
should be changed to
size = vsnprintf(NULL, 0, fmt, tmpa);
for clarity.
The line
*str = (char *) malloc(size + 1);
should be changed to
*str = malloc((size + 1) * sizeof(char));
C allows sizeof(char) > 1
. And there is no need
to cast void*
, it just makes it less readable. You
can remove the C++ style comments when you
are at it making to more like C and less like C++.
Please do not use Yoda-statements.
Whilst your implementation is POSIX-compliant,
it is better to measure the resulting string with %zn
.
Most C standard library implementations implements asprintf
.
I don't know about Microsoft's implementations, but apart from
that Plan 9 is the only notable except, but Plan 9's library is quite
different. So this packages feels quite unnecessary, one could
just use a normal libc, or use gnulib.
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.