Small over allocation in each aws_string #776
Labels
bug
This issue is a bug.
investigating
This issue is being investigated and/or work is in progress to resolve the issue.
p3
This is a minor priority issue
Hi !
It seems that
aws_string_new_from_array
is over allocating a bit of memory in each string.Because of the fact that
aws_string
is defined as follow :given alignment constraints in C,
sizeof (struct aws_string)
is24
.The offset in a string struct denoted by
str->bytes
is 16 (allocator is at 0, len is at 8).Now,
aws_string_new_from_array
allocates memory in the following way:so it allocates
24 + length + 1
bytes, while only16 + length + 1
bytes are needed.So every
aws_string
contains 8 too many bytes that will never be accessed at the end of the object.It's really not a lot, but it's an easy fix.
The text was updated successfully, but these errors were encountered: