bug-gnulib
[Top][All Lists]
Advanced

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

Idea for linked-list


From: Simon Josefsson
Subject: Idea for linked-list
Date: Mon, 12 Mar 2007 14:27:24 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.94 (gnu/linux)

I'm looking at Bruno's data structure modules, in particular
linked-list, and consider using it to hold the information related to
all open fd's handled by select() in GnuTLS's gnutls-serv.  One
important feature of our current implementation is that I can register
my custom "free" function, which can do more things than just memory
deallocation:

static void
listener_free (listener_item * j)
{

  if (j->http_request)
    free (j->http_request);
  if (j->http_response)
    free (j->http_response);
  if (j->fd >= 0)
    {
      gnutls_bye (j->tls_session, GNUTLS_SHUT_WR);
      shutdown (j->fd, 2);
      close (j->fd);
      gnutls_deinit (j->tls_session);
    }
}

This function is invoked for each list item that for any reason is
being removed from the list.  Is it possible to do this with the
linked-list module?  By reading gl_anylinked_list2.h it appear as
de-allocating a list item is pretty hard coded, and several function
do 'free' on it.

I imagine some function to register a "free"-handler, and it would be
used by all other functions that want to de-allocate a particular
node.

Thoughts?

/Simon




reply via email to

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