mmueller / clog Goto Github PK
View Code? Open in Web Editor NEWLightweight logger for C/C++ programs, implemented as a single header file.
Lightweight logger for C/C++ programs, implemented as a single header file.
In CGDB, we don't use O_APPEND and we do use O_TRUNC.
Can this be configurable?
In our use of clog we have this in clog_free,
if (_clog_loggers[id]) {
if (_clog_loggers[id]->opened) {
close( _clog_loggers[ id ]->fd );
}
free( _clog_loggers[ id ] );
_clog_loggers[ id ] = 0;
Does this make sense?
where use the function clog_free to free logger,you forgot to set _clog_loggers[id] to NULL,when you second to init a logger which id equal to before,the function clog_init_fd judge the logger is not NULL and return 1
in function _clog_log()
/* Format the message text with the argument list. */
result = vsnprintf(dynbuf, buf_size, fmt, ap);
if ((size_t) result >= buf_size) {
buf_size = result + 1;
dynbuf = (char *) malloc(buf_size);
result = vsnprintf(dynbuf, buf_size, fmt, ap);
if ((size_t) result >= buf_size) {
/* Formatting failed -- too large */
_clog_err("Formatting failed (1).\n");
free(dynbuf);
return;
}
}
according to vsnprintf manpage:
The functions vprintf(), vfprintf(), vsprintf(), vsnprintf() are equivalent to the functions printf(), fprintf(), sprintf(), snprintf(), respectively, except that they are called with a va_list instead of a variable number of arguments. These functions do not call the va_end macro. Because they invoke the va_arg macro, the value of ap is undefined after the call. See stdarg(3).
So, the second call to vsnprintf
result = vsnprintf(dynbuf, buf_size, fmt, ap);
may cause segment fault.
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.