[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gdsl-general] Pb in gdsl_stack_insert
From: |
Mathieu Clabaut |
Subject: |
[gdsl-general] Pb in gdsl_stack_insert |
Date: |
Fri, 15 Apr 2005 10:39:10 +0200 |
I'm wondering if the following code in gdsl_stack_insert is good, and
particularly the 'if' condition :
if (s->card == s->growing_factor)
{
s->nodes = realloc (s->nodes, (1 + s->size + s->growing_factor)
* sizeof (gdsl_element_t));
if (s->nodes == NULL)
{
s->free_f (e);
return NULL;
}
s->size += s->growing_factor;
}
indeed, nodes are reallocated only if the stack contains
growing_factor elements, which is not at all related to the allocated
nodes s->size ....
I think that the test should be replaced by
if (s->card == s->size)
-mat
--
____________http://www.gnu.org/philosophy/no-word-attachments.fr.html
Mathieu CLABAUT mailto:address@hidden
F2F5 442F F2AC E1D5 9D31 3EFC 842A BC4A 123B 9A65
- [gdsl-general] Pb in gdsl_stack_insert,
Mathieu Clabaut <=