From a131e83b6af273b088632048da593fe20f356f29 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Wed, 6 Apr 2005 19:09:10 +0000 Subject: [PATCH] Changed the initial allocation from liste->nmax = ((n - 1) / liste->incr + 1) * liste->incr, which does not allow us to allocate lists smaller than iste->incr, to liste->nmax = n; With this change, when we do "List_Create(1, N, sizeof(blah))", we initially only allocate sizeof(blah) instead of N*sizeof(blah). --- DataStr/List.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/DataStr/List.cpp b/DataStr/List.cpp index d588dfd265..d15f081d33 100644 --- a/DataStr/List.cpp +++ b/DataStr/List.cpp @@ -1,4 +1,4 @@ -// $Id: List.cpp,v 1.35 2005-04-05 05:56:48 geuzaine Exp $ +// $Id: List.cpp,v 1.36 2005-04-06 19:09:10 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -71,7 +71,10 @@ void List_Realloc(List_T * liste, int n) return; if(liste->array == NULL) { - liste->nmax = ((n - 1) / liste->incr + 1) * liste->incr; + // This does not permit to allocate lists smaller that liste->incr: + //liste->nmax = ((n - 1) / liste->incr + 1) * liste->incr; + // So this is much better + liste->nmax = n; liste->array = (char *)Malloc(liste->nmax * liste->size); } else if(n > liste->nmax) { -- GitLab