X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/fe66dea314bdfd12ce0d8ecfd214b174d3d218ea..de6f834747f9af2af9f110ee3ba3bb9f3f0d01f3:/src/xbt/swag.c diff --git a/src/xbt/swag.c b/src/xbt/swag.c index 9cc8cecab9..3c2793a3aa 100644 --- a/src/xbt/swag.c +++ b/src/xbt/swag.c @@ -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 @@ -13,11 +15,13 @@ #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; }