change multiple if statements by isspace() + uneeded memset
Ricardo Jose Maraschini
ricardo.maraschini at opservices.com.br
Tue Nov 27 14:51:16 CET 2012
Hya,
calloc already sets memory to 0 and i think that if we already have
a function to verify if a given char is an space, we should use it.
ok? comments?
-rm
===================================================================
--- lib/pqueue.c (revision 2482)
+++ lib/pqueue.c (working copy)
@@ -47,7 +47,6 @@
free(q);
return NULL;
}
- memset(q->d, 0, (n + 1) * sizeof(void *));
q->size = 1;
q->avail = q->step = (n + 1); /* see comment above about n+1 */
Index: base/nagiostats.c
===================================================================
--- base/nagiostats.c (revision 2482)
+++ base/nagiostats.c (working copy)
@@ -1349,7 +1349,7 @@
/* strip end of string */
y = (int)strlen(buffer);
for(x = y - 1; x >= 0; x--) {
- if(buffer[x] == ' ' || buffer[x] == '\n' || buffer[x] == '\r' || buffer[x] == '\t' || buffer[x] == 13)
+ if(isspace(buffer[x]))
buffer[x] = '\x0';
else
break;
@@ -1358,7 +1358,7 @@
/* strip beginning of string (by shifting) */
y = (int)strlen(buffer);
for(x = 0; x < y; x++) {
- if(buffer[x] == ' ' || buffer[x] == '\n' || buffer[x] == '\r' || buffer[x] == '\t' || buffer[x] == 13)
+ if(isspace(buffer[x]))
continue;
else
break;
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
More information about the Developers
mailing list