- updated code to protect against null pointers and uninitialized values and threading issues

This commit is contained in:
Mark Vejvoda
2013-02-04 08:30:43 +00:00
parent d02f91d2e0
commit f87b8b6ee2
35 changed files with 332 additions and 188 deletions

View File

@@ -218,12 +218,14 @@ namespace Shared { namespace Util {
void strrev(char *p) {
char *q = p;
while(q && *q) ++q;
for(--q; p < q; ++p, --q)
*p = *p ^ *q,
*q = *p ^ *q,
*p = *p ^ *q;
if(p != NULL) {
char *q = p;
while(q && *q) ++q;
for(--q; p < q; ++p, --q)
*p = *p ^ *q,
*q = *p ^ *q,
*p = *p ^ *q;
}
}
#define SWP(x,y) (x^=y, y^=x, x^=y)