On Mon, Sep 21, 2009 at 9:53 PM, Diego Medina <[email protected]> wrote:
> Hi,
>
> In libdrizzle/column.c:355 we have:
>
> void drizzle_column_free(drizzle_column_st *column)
> {
>  if (column->result->column_list == column)
>    column->result->column_list= column->next;
>  if (column->prev)
>    column->prev->next= column->next;
>  if (column->next)
>    column->next->prev= column->prev;
>
>  if (column->options & DRIZZLE_COLUMN_ALLOCATED)
>    free(column);
> }
>
> why can't is just be
>
>  if (column->options & DRIZZLE_COLUMN_ALLOCATED)
>    free(column);

From not knowing the above code, it looks to me like it is removing
column from a doubly-linked list before freeing the memory allocated
for column. This statement:

if (column->result->column_list == column)
  column->result->column_list= column->next;

looks like it modifies the head of the linked list i.e. if the node to
be deleted is the head, modify the head to point to the next in the
list.

These statements:

if (column->prev)
  column->prev->next= column->next;
if (column->next)
  column->next->prev= column->prev;

just splice the node to be deleted out of the linked list by modifying
the successor and predecessor pointers of column's successor and
predecessor.

So yeah, I would assume this code is needed.

-Padraig

>
> ?
>
> Thanks
>
>   -Diego
>
> P.S. oh, why do I ask, there are times when
> column->result->column_list  points to an address that cannot be
> accessed (like in this bug
> https://bugs.launchpad.net/drizzle/+bug/432210 )
> I fixed that one bug, but now I see a new one because
> column->prev->next is in an address that cannot be accessed :|
>
>
>
>
>
> --
> Diego Medina
> Web Developer
> http://www.fmpwizard.com
>
> _______________________________________________
> Mailing list: https://launchpad.net/~drizzle-discuss
> Post to     : [email protected]
> Unsubscribe : https://launchpad.net/~drizzle-discuss
> More help   : https://help.launchpad.net/ListHelp
>

_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help   : https://help.launchpad.net/ListHelp

Reply via email to