refstr_get(): handle NULL, force inline
authorH. Peter Anvin <hpa@zytor.com>
Tue, 19 Feb 2008 22:08:06 +0000 (14:08 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Wed, 20 Feb 2008 00:51:23 +0000 (16:51 -0800)
Make refstr_get() handle NULL correctly; force it to be an inline
since it seems to make no difference for code size.

com32/menu/refstr.h

index 593b0ab..8bec018 100644 (file)
 #include <stddef.h>
 #include <stdarg.h>
 
-static inline const char *refstr_get(const char *r)
+static inline __attribute__((always_inline))
+const char *refstr_get(const char *r)
 {
-  unsigned int *ref = (unsigned int *)r - 1;
-  ref++;
+  if (r)
+    ((unsigned int *)r)[-1]++;
   return r;
 }