Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of framagit.org:simgrid/simgrid
[simgrid.git] / src / xbt / mmalloc / swag.c
index 4d2e212..eff8368 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2004-2017. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2004-2023. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -11,7 +10,7 @@
 /* This type should be added to a type that is to be used in such a swag */
 
 #include "swag.h"
-#include "xbt/asserts.h"
+#include "mmprivate.h" // mmalloc_assert
 
 typedef s_xbt_swag_hookup_t *xbt_swag_hookup_t;
 typedef struct xbt_swag* xbt_swag_t;
@@ -23,14 +22,14 @@ typedef const struct xbt_swag* const_xbt_swag_t;
 
 static inline void *xbt_swag_getFirst(const_xbt_swag_t swag)
 {
-  return (swag->head);
+  return swag->head;
 }
 
 /*
- * \brief Offset computation
- * \arg var a variable of type <tt>struct</tt> something
- * \arg field a field of <tt>struct</tt> something
- * \return the offset of \a field in <tt>struct</tt> something.
+ * @brief Offset computation
+ * @arg var a variable of type <tt>struct</tt> something
+ * @arg field a field of <tt>struct</tt> something
+ * @return the offset of @a field in <tt>struct</tt> something.
  * @hideinitializer
  *
  * It is very similar to offsetof except that is done at runtime and that you have to declare a variable. Why defining
@@ -40,9 +39,9 @@ static inline void *xbt_swag_getFirst(const_xbt_swag_t swag)
 /* @} */
 
 /* Creates a new swag.
- * \param swag the swag to initialize
- * \param offset where the hookup is located in the structure
- * \see xbt_swag_offset
+ * @param swag the swag to initialize
+ * @param offset where the hookup is located in the structure
+ * @see xbt_swag_offset
  *
  * Usage : xbt_swag_init(swag,&obj.setA-&obj);
  */
@@ -55,19 +54,20 @@ static inline void xbt_swag_init(xbt_swag_t swag, size_t offset)
 }
 
 /*
- * \param obj the objet to insert in the swag
- * \param swag a swag
+ * @param obj the object to insert in the swag
+ * @param swag a swag
  *
- * insert (at the tail... you probably had a very good reason to do that, I hope you know what you're doing) \a obj in
- * \a swag
+ * insert (at the tail... you probably had a very good reason to do that, I hope you know what you're doing) @a obj in
+ * @a swag
  */
 static inline void xbt_swag_insert(void *obj, xbt_swag_t swag)
 {
-  xbt_assert(!xbt_swag_belongs(obj, swag) || swag->tail,
-             "This object belongs to an empty swag! Did you correctly initialize the object's hookup?");
+
+  mmalloc_assert(!xbt_swag_belongs(obj, swag) || swag->tail,
+                 "This object belongs to an empty swag! Did you correctly initialize the object's hookup?");
 
   if (!swag->head) {
-    xbt_assert(!(swag->tail), "Inconsistent swag.");
+    mmalloc_assert(!(swag->tail), "Inconsistent swag.");
     swag->head = obj;
     swag->tail = obj;
     swag->count++;
@@ -80,11 +80,11 @@ static inline void xbt_swag_insert(void *obj, xbt_swag_t swag)
 }
 
 /*
- * \param obj the objet to remove from the swag
- * \param swag a swag
- * \return \a obj if it was in the \a swag and NULL otherwise
+ * @param obj the object to remove from the swag
+ * @param swag a swag
+ * @return @a obj if it was in the @a swag and NULL otherwise
  *
- * removes \a obj from \a swag
+ * removes @a obj from @a swag
  */
 static inline void *xbt_swag_remove(void *obj, xbt_swag_t swag)
 {
@@ -119,10 +119,10 @@ static inline void *xbt_swag_remove(void *obj, xbt_swag_t swag)
 }
 
 /*
- * \param swag a swag
- * \return the number of objects in \a swag
+ * @param swag a swag
+ * @return the number of objects in @a swag
  */
 static inline int xbt_swag_size(const_xbt_swag_t swag)
 {
-  return (swag->count);
+  return swag->count;
 }