Code auditing weekend results and fixes committing.
[silc.git] / lib / silccore / silcsockconn.c
1 /*
2
3   silcsockconn.c
4
5   Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
6
7   Copyright (C) 1997 - 2000 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; either version 2 of the License, or
12   (at your option) any later version.
13   
14   This program is distributed in the hope that it will be useful,
15   but WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   GNU General Public License for more details.
18
19 */
20 /*
21  * $Id$
22  * $Log$
23  * Revision 1.3  2001/02/11 14:09:34  priikone
24  *      Code auditing weekend results and fixes committing.
25  *
26  * Revision 1.2  2000/07/05 06:06:35  priikone
27  *      Global cosmetic change.
28  *
29  * Revision 1.1.1.1  2000/06/27 11:36:55  priikone
30  *      Imported from internal CVS/Added Log headers.
31  *
32  *
33  */
34
35 #include "silcincludes.h"
36
37 /* Allocates a new socket connection object. The allocated object is 
38    returned to the new_socket argument. */
39
40 void silc_socket_alloc(int sock, SilcSocketType type, void *user_data, 
41                        SilcSocketConnection *new_socket)
42 {
43   SILC_LOG_DEBUG(("Allocating new socket connection object"));
44
45   /* Set the pointers. Incoming and outgoing data buffers
46      are allocated by the server when they are first used. */
47   *new_socket = silc_calloc(1, sizeof(**new_socket));
48   (*new_socket)->sock = sock;
49   (*new_socket)->type = type;
50   (*new_socket)->user_data = user_data;
51   (*new_socket)->protocol = NULL;
52   (*new_socket)->flags = 0;
53   (*new_socket)->inbuf = NULL;
54   (*new_socket)->outbuf = NULL;
55 }
56
57 /* Free's the Socket connection object. */
58
59 void silc_socket_free(SilcSocketConnection sock)
60 {
61   if (sock) {
62     silc_buffer_free(sock->inbuf);
63     silc_buffer_free(sock->outbuf);
64     silc_free(sock);
65   }
66 }