Fix for lp:860465
[awesomized/libmemcached] / libhashkit / types.h
index 23bd9d5c4f22d2a8b992dbd012ba2ff9a6bc7ba5..e0f1f1387ffc2097723c58e1a438ca4e61ad68b6 100644 (file)
  */
 
 
-#ifndef HASHKIT_TYPES_H
-#define HASHKIT_TYPES_H
-
-#ifdef __cplusplus
-
-extern "C" {
-#endif
+#pragma once
 
 typedef enum {
   HASHKIT_SUCCESS,
@@ -53,6 +47,16 @@ typedef enum {
   HASHKIT_MAXIMUM_RETURN /* Always add new error code before */
 } hashkit_return_t;
 
+static inline bool hashkit_success(const hashkit_return_t rc)
+{
+  return (rc == HASHKIT_SUCCESS);
+}
+
+static inline bool hashkit_failed(const hashkit_return_t rc)
+{
+  return (rc != HASHKIT_SUCCESS);
+}
+
 typedef enum {
   HASHKIT_HASH_DEFAULT= 0, // hashkit_one_at_a_time()
   HASHKIT_HASH_MD5,
@@ -79,6 +83,9 @@ typedef enum
   HASHKIT_DISTRIBUTION_MAX /* Always add new values before this. */
 } hashkit_distribution_t;
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 typedef struct hashkit_st hashkit_st;
 
@@ -87,5 +94,3 @@ typedef uint32_t (*hashkit_hash_fn)(const char *key, size_t key_length, void *co
 #ifdef __cplusplus
 }
 #endif
-
-#endif /* HASHKIT_TYPES_H */