From 3192976f19afbfb9321f9ed404c455d9bd5c532f Mon Sep 17 00:00:00 2001 From: hasherezade Date: Mon, 21 Apr 2025 03:37:15 +0000 Subject: [PATCH] deploy: cf42205f9e0e89e036c4293b01a6df6fe4d4e45e --- _byte_buffer_8cpp_source.html | 87 +++++++++++++++-------------------- _byte_buffer_8h_source.html | 4 +- class_byte_buffer.html | 4 +- 3 files changed, 42 insertions(+), 53 deletions(-) diff --git a/_byte_buffer_8cpp_source.html b/_byte_buffer_8cpp_source.html index 753b9398..d8b79de4 100644 --- a/_byte_buffer_8cpp_source.html +++ b/_byte_buffer_8cpp_source.html @@ -153,58 +153,47 @@ $(function(){ initResizable(false); });
52BYTE* ByteBuffer::allocContent(bufsize_t v_size, bufsize_t v_padding)
53{
54 if (!v_size) throw BufferException("Zero size requested");
-
55
+
55
56 const bufsize_t allocSize = v_size + v_padding;
-
57 std::cerr << "Trying to resize. Ptr: " << std::hex << (void*)content << " New size: " << allocSize << std::endl;
+
57 const bufsize_t sizeDiff = (allocSize > this->contentSize) ? (allocSize - this->contentSize) : 0;
58
-
59 const bufsize_t sizeDiff = (allocSize > this->contentSize) ? (allocSize - this->contentSize) : 0;
-
60 BYTE* content = reinterpret_cast<BYTE*>(::realloc((void*)this->content, allocSize));
-
61
-
62 if (!content) {
-
63 std::cerr << "Error!" << std::endl;
-
64 throw BufferException("Cannot allocate buffer of size: 0x" + QString::number(allocSize, 16));
+
59 BYTE* content = reinterpret_cast<BYTE*>(::realloc((void*)this->content, allocSize));
+
60 if (!content) {
+
61 throw BufferException("Cannot allocate buffer of size: 0x" + QString::number(allocSize, 16));
+
62 }
+
63 if (sizeDiff) {
+
64 ::memset(content + this->contentSize, 0, sizeDiff);
65 }
-
66 if (sizeDiff) {
-
67 std::cerr << "Ptr: " << std::hex << (void*)content << " Additional size: " << sizeDiff << " BaseContentSize: " << this->contentSize << std::endl;
-
68 ::memset(content + this->contentSize, 0, sizeDiff);
-
69 } else {
-
70 std::cerr << "Ptr: " << std::hex << (void*)content << " New size: " << allocSize << std::endl;
-
71 }
-
72 /*if (sizeDiff) {
-
73 // if some memory has been added to the existing buffer, initialize it with 0
-
74 ::memset(content + this->contentSize, 0, sizeDiff);
-
75 }*/
-
76 return content;
-
77}
+
66 return content;
+
67}
-
78
-
- -
80{
-
81 if (newSize == this->contentSize) {
-
82 return true;
-
83 }
-
84 BYTE *newContent = nullptr;
-
85 bool isOk = true;
-
86 try {
-
87 newContent = allocContent(newSize, this->padding);
-
88 if (newContent) {
-
89 this->content = newContent;
-
90 this->contentSize = newSize;
-
91 }
-
92 } catch (const BufferException&) {
-
93 isOk = false;
-
94 }
-
95 return isOk;
-
96}
+
68
+
+ +
70{
+
71 if (newSize == this->contentSize) {
+
72 return true;
+
73 }
+
74 BYTE *newContent = nullptr;
+
75 bool isOk = true;
+
76 try {
+
77 newContent = allocContent(newSize, this->padding);
+
78 if (newContent) {
+
79 this->content = newContent;
+
80 this->contentSize = newSize;
+
81 }
+
82 } catch (const BufferException&) {
+
83 isOk = false;
+
84 }
+
85 return isOk;
+
86}
-
97
-
- -
99{
-
100 std::cerr << "Ptr: " << std::hex << (void*)content << " BaseContentSize: " << this->contentSize << " : " << __FUNCTION__ << std::endl;
-
101 ::free(this->content);
-
102}
+
87
+
+ +
89{
+
90 ::free(this->content);
+
91}
uint32_t bufsize_t
uint64_t offset_t
@@ -215,13 +204,13 @@ $(function(){ initResizable(false); });
bufsize_t originalSize
Definition ByteBuffer.h:44
BYTE * content
Definition ByteBuffer.h:40
-
virtual ~ByteBuffer()
+
virtual ~ByteBuffer()
bufsize_t contentSize
Definition ByteBuffer.h:41
ByteBuffer(bufsize_t v_size, bufsize_t padding=DEFAULT_PADDING)
Definition ByteBuffer.cpp:4
size_t m_refs
Definition ByteBuffer.h:46
BYTE * allocContent(bufsize_t v_size, bufsize_t padding)
bufsize_t padding
Definition ByteBuffer.h:42
-
virtual bool resize(bufsize_t newSize)
+
virtual bool resize(bufsize_t newSize)