Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Tss... lead to inconsistencies.
[simgrid.git] / src / xbt / swag.c
index 9cc8cec..3c2793a 100644 (file)
@@ -1,7 +1,9 @@
-/* Authors: Arnaud Legrand                                                  */
+/*     $Id$     */
+
+/* Copyright (c) 2004 Arnaud Legrand. 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. */
* under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* Warning, this module is done to be efficient and performs tons of
    cast and dirty things. So avoid using it unless you really know
 #include "xbt/error.h"
 #include "xbt/swag.h"
 
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(swag,xbt,"Swag : O(1) set library");
+
 #define PREV(obj,offset) xbt_swag_getPrev(obj,offset)
 #define NEXT(obj,offset) xbt_swag_getNext(obj,offset)
 
 /*
-  Usage : xbt_swag_new(&obj.setA-&obj.setA);
+  Usage : xbt_swag_new(&obj.setA-&obj);
  */
 
 xbt_swag_t xbt_swag_new(size_t offset)
@@ -29,6 +33,12 @@ xbt_swag_t xbt_swag_new(size_t offset)
   return swag;
 }
 
+
+void xbt_swag_free(xbt_swag_t swag)
+{
+  xbt_free(swag);
+}
+
 void xbt_swag_init(xbt_swag_t swag, size_t offset)
 {
   swag->offset = offset;
@@ -102,6 +112,7 @@ void *xbt_swag_extract(xbt_swag_t swag)
     PREV(swag->head, offset) = NULL;
     NEXT(obj, offset) = NULL;
   }
+  (swag->count)--;
 
   return obj;
 }