From 809fe0d67eb39f9ec08bca65735241803bc923f3 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sat, 8 Oct 2011 17:05:19 +0000 Subject: Correction du bug de zoom (c'était juste le calcul de "pos" qui était foireux). Création des méthodes sliceDelete et slicesDelete et utilisation à la fin du main. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///var/svn/2011-ddhardrescue/trunk@25 d3078510-dda0-49f1-841c-895ef4b7ec81 --- src/slices.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/slices.c') diff --git a/src/slices.c b/src/slices.c index 36f7bb1..06fa1b7 100644 --- a/src/slices.c +++ b/src/slices.c @@ -20,6 +20,10 @@ slice_t *sliceNew(address_t begin, address_t end, sliceStatus_t status, slice_t return s; } +void sliceDelete(slice_t *s) { + free(s); +} + // Return the numbers of slices after split (3 in the general case, 2 or 1 in particular cases. -1 is memory error) int sliceSplit(slices_t *slices, slice_t *initialSlice, address_t splitAt, sliceStatus_t statusBefore, sliceStatus_t statusAt, sliceStatus_t statusAfter) { slice_t *secondSlice, *thirdSlice, *rightSlice; @@ -122,6 +126,18 @@ slices_t *slicesNewSingleton(address_t begin, address_t end, sliceStatus_t statu return ss; } +void slicesDelete(slices_t *ss) { + slice_t *curr, *toFree; + + curr=ss->first; + while (curr!=NULL) { + toFree=curr; + curr=curr->next; + sliceDelete(toFree); + } + free(ss); +} + void slicesAppend(slices_t *slices, slice_t *slice) { pthread_mutex_lock(&(slices->writeOrConsistentReadMutex)); -- cgit v1.2.3