Skip to content

Commit

Permalink
Add a deconstructor to the string implementation (#85)
Browse files Browse the repository at this point in the history
Allows us to free the memory when the string is deallocated.
  • Loading branch information
4z0t authored Sep 23, 2024
1 parent 591d114 commit 9c0a6be
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions section/include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,18 @@ struct basic_string {
const T* data() {
return size < sso_size ? &str : *(const T**)str;
}

~basic_string()
{
if(size >= sso_size)
{
free(data());
}
ptr = 0;
str[0] = T(0);
strLen = 0;
size = sso_size - 1;
}
};

VALIDATE_SIZE(string, 0x1C)
Expand Down

0 comments on commit 9c0a6be

Please sign in to comment.