[Nagiosplug-devel] replacing common system calls with macros/inlines?
sean finney
seanius at seanius.net
Tue Mar 21 14:55:07 CET 2006
a thought for consideration:
currently, there are a large number of places in plugin code
where we have stuff like
...
foo=strdup(bar);
if(foo==NULL) {
printf("error message");
exit(STATE_UNKNOWN);
}
...
does it make any sense to introduce some macros to condense
code a bit? for example:
static inline char* STRDUP(const char *foo){
char *bar;
bar=strdup(foo);
if(bar==NULL){
printf("error message");
exit(STATE_UNKNOWN);
}
}
and then everywhere in our plugin code we could replace the strdup()+error
detection calls with STRDUP(), and save ourselves some lines of code in
many places (and introduce missing/needed error checking in others).
likewise, a similar approach could be taken for malloc, fopen, and
probably others...
thoughts?
sean
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://nagios-plugins.org/archive/devel/attachments/20060321/2017938d/attachment.sig>
More information about the Devel
mailing list