Skip to content

Commit

Permalink
add API for creating dynamically sized byte buf
Browse files Browse the repository at this point in the history
  • Loading branch information
sbiscigl committed May 9, 2024
1 parent a832631 commit d9318b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/aws/crt/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ namespace Aws
AWS_CRT_CPP_API ByteBuf ByteBufFromEmptyArray(const uint8_t *array, size_t len) noexcept;
AWS_CRT_CPP_API ByteBuf ByteBufFromArray(const uint8_t *array, size_t capacity) noexcept;
AWS_CRT_CPP_API ByteBuf ByteBufNewCopy(Allocator *alloc, const uint8_t *array, size_t len);
AWS_CRT_CPP_API ByteBuf ByteBufInit(Allocator *alloc, size_t len);
AWS_CRT_CPP_API void ByteBufDelete(ByteBuf &);

AWS_CRT_CPP_API ByteCursor ByteCursorFromCString(const char *str) noexcept;
Expand Down
7 changes: 7 additions & 0 deletions source/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ namespace Aws
return retVal;
}

ByteBuf ByteBufInit(Allocator *alloc, size_t len)
{
ByteBuf buff;
aws_byte_buf_init(&buff, alloc, len);
return buff;
}

void ByteBufDelete(ByteBuf &buf) { aws_byte_buf_clean_up(&buf); }

ByteCursor ByteCursorFromCString(const char *str) noexcept { return aws_byte_cursor_from_c_str(str); }
Expand Down

0 comments on commit d9318b3

Please sign in to comment.