Skip to content
Snippets Groups Projects
Commit a131e83b authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

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).
parent 749e1550
No related branches found
No related tags found
No related merge requests found
// $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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment