Use bool instead of bool:1 if your compiler doesn't create correct code
[awesomized/libmemcached] / libmemcached / string.h
index 9e064d9ad117808475c6b7f692907101e841e6b2..605ac57ba4c7e664e215f5e2c81082f24f7a32f4 100644 (file)
@@ -9,19 +9,15 @@
  *
  */
 
-#ifndef __MEMCACHED_STRING_H__
-#define __MEMCACHED_STRING_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+#ifndef __LIBMEMCACHED_STRING_H__
+#define __LIBMEMCACHED_STRING_H__
 
 /**
   Strings are always under our control so we make some assumptions
   about them.
 
   1) is_initialized is always valid.
-  2) A string once intialized will always be, until free where we 
+  2) A string once intialized will always be, until free where we
      unset this flag.
   3) A string always has a root.
 */
@@ -32,32 +28,14 @@ struct memcached_string_st {
   size_t current_size;
   const memcached_st *root;
   struct {
-    bool is_allocated:1;
-    bool is_initialized:1;
+    bool is_allocated MEMCACHED_BITFIELD;
+    bool is_initialized MEMCACHED_BITFIELD;
   } options;
 };
 
-static inline size_t memcached_string_length(const memcached_string_st *self)
-{
-  return (size_t)(self->end - self->string);
-}
-
-static inline size_t memcached_string_size(const memcached_string_st *self)
-{
-  return self->current_size;
-}
-
-static inline const char *memcached_string_value(const memcached_string_st *self)
-{
-  return self->string;
-}
-
-static inline char *memcached_string_value_mutable(const memcached_string_st *self)
-{
-  return self->string;
-}
-
-#define memcached_string_set_length(A, B) (A)->end= (A)->string + B
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 LIBMEMCACHED_LOCAL
 memcached_string_st *memcached_string_create(const memcached_st *ptr,
@@ -81,8 +59,31 @@ memcached_return_t memcached_string_reset(memcached_string_st *string);
 LIBMEMCACHED_LOCAL
 void memcached_string_free(memcached_string_st *string);
 
+static inline size_t memcached_string_length(const memcached_string_st *self)
+{
+  return (size_t)(self->end - self->string);
+}
+
+static inline size_t memcached_string_size(const memcached_string_st *self)
+{
+  return self->current_size;
+}
+
+static inline const char *memcached_string_value(const memcached_string_st *self)
+{
+  return self->string;
+}
+
+static inline char *memcached_string_value_mutable(const memcached_string_st *self)
+{
+  return self->string;
+}
+
+#define memcached_string_set_length(A, B) (A)->end= (A)->string + B
+
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* __MEMCACHED_STRING_H__ */
+
+#endif /* __LIBMEMCACHED_STRING_H__ */