Bläddra i källkod

Allow inlining list_*

Bryan Drewery 7 år sedan
förälder
incheckning
b05235698f
2 ändrade filer med 30 tillägg och 30 borttagningar
  1. 0 27
      src/userent.cc
  2. 30 3
      src/users.h

+ 0 - 27
src/userent.cc

@@ -1050,33 +1050,6 @@ struct user_entry_type USERENTRY_HOSTS =
   "HOSTS"
 };
 
-bool list_append(struct list_type **h, struct list_type *i)
-{
-  for (; *h; h = &((*h)->next))
-    ;
-  *h = i;
-  return 1;
-}
-
-bool list_delete(struct list_type **h, struct list_type *i)
-{
-  for (; *h; h = &((*h)->next))
-    if (*h == i) {
-      *h = i->next;
-      return 1;
-    }
-  return 0;
-}
-
-bool list_contains(struct list_type *h, struct list_type *i)
-{
-  for (; h; h = h->next)
-    if (h == i) {
-      return 1;
-    }
-  return 0;
-}
-
 bool add_entry_type(struct user_entry_type *type)
 {
   struct userrec *u = NULL;

+ 30 - 3
src/users.h

@@ -21,9 +21,36 @@ struct list_type {
     	(b)->next = *(a);						\
 	*(a) = (b);							\
 }
-bool list_append(struct list_type **, struct list_type *);
-bool list_delete(struct list_type **, struct list_type *);
-bool list_contains(struct list_type *, struct list_type *);
+
+static inline bool
+list_append(struct list_type **h, struct list_type *i)
+{
+  for (; *h; h = &((*h)->next))
+    ;
+  *h = i;
+  return 1;
+}
+
+static inline bool
+list_delete(struct list_type **h, struct list_type *i)
+{
+  for (; *h; h = &((*h)->next))
+    if (*h == i) {
+      *h = i->next;
+      return 1;
+    }
+  return 0;
+}
+
+static inline bool
+list_contains(struct list_type *h, struct list_type *i)
+{
+  for (; h; h = h->next)
+    if (h == i) {
+      return 1;
+    }
+  return 0;
+}
 
 namespace bd {
   class Stream;