Blame view

libproto/pop/pop3_destroy.c 1.55 KB
Sergey Poznyakoff authored
1
/* GNU Mailutils -- a suite of utilities for electronic mail
2
   Copyright (C) 2003, 2007, 2010 Free Software Foundation, Inc.
Sergey Poznyakoff authored
3 4 5 6

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
7
   version 3 of the License, or (at your option) any later version.
Sergey Poznyakoff authored
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General
   Public License along with this library; if not, write to the
   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301 USA */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <stdlib.h>
#include <mailutils/errno.h>
#include <mailutils/sys/pop3.h>
26
#include <mailutils/list.h>
Sergey Poznyakoff authored
27 28 29 30 31 32 33 34 35

void
mu_pop3_destroy (mu_pop3_t *ppop3)
{
  if (ppop3 && *ppop3)
    {
      mu_pop3_t pop3 = *ppop3;

      /* Free the response buffer.  */
36 37 38 39 40
      if (pop3->ackbuf)
	free (pop3->ackbuf);
      /* Free the read buffer.  */
      if (pop3->rdbuf)
	free (pop3->rdbuf);
Sergey Poznyakoff authored
41 42 43 44 45

      /* Free the timestamp use for APOP.  */
      if (pop3->timestamp)
	free (pop3->timestamp);

46 47
      mu_list_destroy (&pop3->capa);
      
Sergey Poznyakoff authored
48 49
      /* Release the carrier.  */
      if (pop3->carrier)
50
	mu_stream_destroy (&pop3->carrier);
Sergey Poznyakoff authored
51 52 53 54 55 56

      free (pop3);

      *ppop3 = NULL;
    }
}