summaryrefslogtreecommitdiff
path: root/src/or/hs_cell.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2017-08-22 14:37:33 -0400
committerDavid Goulet <dgoulet@torproject.org>2017-08-24 13:03:28 -0400
commit7c543412fc4c77a58fb928c6eb322e48fae97137 (patch)
tree068ec9e1fc14c5466fdc2a864faf7be9f04dcf38 /src/or/hs_cell.c
parentcb462b95b7e864b71ea3dc0a6bfb76c30fb8d378 (diff)
downloadtor-7c543412fc4c77a58fb928c6eb322e48fae97137.tar.gz
tor-7c543412fc4c77a58fb928c6eb322e48fae97137.zip
prop224: Add a function to clear INTRO data
New function named hs_cell_introduce1_data_clear() is introduced to clear off an hs_cell_introduce1_data_t object. Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/hs_cell.c')
-rw-r--r--src/or/hs_cell.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/or/hs_cell.c b/src/or/hs_cell.c
index 482fa04e92..5244cfa3dd 100644
--- a/src/or/hs_cell.c
+++ b/src/or/hs_cell.c
@@ -931,3 +931,18 @@ hs_cell_parse_rendezvous2(const uint8_t *payload, size_t payload_len,
return ret;
}
+/* Clear the given INTRODUCE1 data structure data. */
+void
+hs_cell_introduce1_data_clear(hs_cell_introduce1_data_t *data)
+{
+ if (data == NULL) {
+ return;
+ }
+ /* Object in this list have been moved to the cell object when building it
+ * so they've been freed earlier. We do that in order to avoid duplicating
+ * them leading to more memory and CPU time being used for nothing. */
+ smartlist_free(data->link_specifiers);
+ /* The data object has no ownership of any members. */
+ memwipe(data, 0, sizeof(hs_cell_introduce1_data_t));
+}
+