[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 7/8] mbuffers: Add _mbuffer_xfree operation.
From: |
Jonathan Bastien-Filiatrault |
Subject: |
[PATCH 7/8] mbuffers: Add _mbuffer_xfree operation. |
Date: |
Wed, 8 Sep 2010 18:34:46 -0400 |
Signed-off-by: Jonathan Bastien-Filiatrault <address@hidden>
diff --git a/lib/gnutls_mbuffers.h b/lib/gnutls_mbuffers.h
index 8f08a96..beb1eab 100644
--- a/lib/gnutls_mbuffers.h
+++ b/lib/gnutls_mbuffers.h
@@ -25,7 +25,8 @@
#ifndef GNUTLS_MBUFFERS_H
# define GNUTLS_MBUFFERS_H
-#include "gnutls_int.h"
+#include <gnutls_int.h>
+#include <gnutls_errors.h>
void _mbuffer_init (mbuffer_head_st *buf);
void _mbuffer_clear (mbuffer_head_st *buf);
@@ -95,4 +96,18 @@ inline static mbuffer_st* _gnutls_handshake_alloc(size_t
size, size_t maximum)
return ret;
}
+/* Free a segment, if the pointer is not NULL
+ *
+ * We take a ** to detect and fix double free bugs (the dangling
+ * pointer case). It also makes sure the pointer has a known value
+ * after freeing.
+ */
+inline static void _mbuffer_xfree(mbuffer_st **bufel)
+{
+ if(*bufel)
+ gnutls_free(*bufel);
+
+ *bufel = NULL;
+}
+
#endif
--
1.7.1
- [PATCH] Read-side mbuffers, Jonathan Bastien-Filiatrault, 2010/09/08
- [PATCH 1/8] mbuffers: Document the internal mbuffer API., Jonathan Bastien-Filiatrault, 2010/09/08
- [PATCH 2/8] mbuffers: Make _mbuffer_remove_bytes return a meaningful error code., Jonathan Bastien-Filiatrault, 2010/09/08
- [PATCH 3/8] mbuffers: fix wrong size calculation., Jonathan Bastien-Filiatrault, 2010/09/08
- [PATCH 5/8] Parenthesize size calculations., Jonathan Bastien-Filiatrault, 2010/09/08
- [PATCH 4/8] mbuffers: Add mbuffer_linearize., Jonathan Bastien-Filiatrault, 2010/09/08
- [PATCH 6/8] mbuffers: make _gnutls_io_read_buffered use mbuffers., Jonathan Bastien-Filiatrault, 2010/09/08
- [PATCH 8/8] Fully mbufferize _gnutls_read and _gnutls_read_buffered., Jonathan Bastien-Filiatrault, 2010/09/08
- [PATCH 7/8] mbuffers: Add _mbuffer_xfree operation.,
Jonathan Bastien-Filiatrault <=
- Re: [PATCH] Read-side mbuffers, Nikos Mavrogiannopoulos, 2010/09/09