gdsl-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gdsl-general] Pb in gdsl_stack_insert


From: Nicolas Darnis
Subject: Re: [gdsl-general] Pb in gdsl_stack_insert
Date: Fri, 15 Apr 2005 14:56:48 +0200
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050324)

Mathieu Clabaut wrote:
 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

Hi Mathieu,

you're perfectly right!

I can add your name in the THANKS file if you allow me to do it.

Thank you for this bug report.

Best regards,

--
Nicolas Darnis
Tel: (+33) 556 710 097
GPG 0x6B794D9E:    051F 3035 0183 A6DD 2701 A773 EE05 821E 6B79 4D9E




reply via email to

[Prev in Thread] Current Thread [Next in Thread]