cleanup: replace membuffer by membufferpp in C-code

Thus, the membuffer data is automatically freed when going
out of scope - one thing less to worry about.

This fixes one use-after-free bug in uploadDiveLogsDE.cpp
and one extremely questionable practice in divetooltipitem.cpp:
The membuffer was a shared instance across all instances
of the DiveToolTipItem.

Remves unnecessary #include directives in files that didn't
even use membuffer.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-07-20 07:45:31 +02:00 committed by Dirk Hohndel
parent f142e9a9c6
commit 16b31985c3
9 changed files with 9 additions and 21 deletions

View file

@ -128,13 +128,12 @@ void TabDivePhotos::saveSubtitles()
// Only videos have non-zero duration
if (!duration)
continue;
struct membuffer b = { 0 };
struct membufferpp b;
save_subtitles_buffer(&b, current_dive, offset, duration);
char *data = detach_cstring(&b);
const char *data = mb_cstring(&b);
subtitlefile.open(QIODevice::WriteOnly);
subtitlefile.write(data, strlen(data));
subtitlefile.close();
free(data);
}
}
}