comparison th_network.c @ 122:452adc41ccf5

Remember to free the connection data buffer.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 22 Jun 2014 02:45:06 +0300
parents 8c39e8e90dbd
children c8584cf52c98
comparison
equal deleted inserted replaced
121:8c39e8e90dbd 122:452adc41ccf5
121 th_conn_t *conn = th_malloc0(sizeof(th_conn_t)); 121 th_conn_t *conn = th_malloc0(sizeof(th_conn_t));
122 122
123 if (conn == NULL) 123 if (conn == NULL)
124 return NULL; 124 return NULL;
125 125
126 // Set function pointers
126 conn->errfunc = errfunc; 127 conn->errfunc = errfunc;
127 conn->msgfunc = msgfunc; 128 conn->msgfunc = msgfunc;
128 129
130 // Allocate connection data buffer
129 conn->bufsize = (bufsize <= 0) ? TH_CONNBUF_SIZE : bufsize; 131 conn->bufsize = (bufsize <= 0) ? TH_CONNBUF_SIZE : bufsize;
130 if ((conn->buf = th_malloc(conn->bufsize)) == NULL) 132 if ((conn->buf = th_malloc(conn->bufsize)) == NULL)
131 { 133 {
132 th_free(conn); 134 th_free(conn);
133 return NULL; 135 return NULL;
676 } 678 }
677 679
678 680
679 static void th_conn_free_nodelete(th_conn_t *conn) 681 static void th_conn_free_nodelete(th_conn_t *conn)
680 { 682 {
683 th_free(conn->buf);
681 th_conn_close(conn); 684 th_conn_close(conn);
682 th_free(conn->host); 685 th_free(conn->host);
683 th_free(conn->proxy.host); 686 th_free(conn->proxy.host);
684 th_free(conn); 687 th_free(conn);
685 } 688 }