forked from facebook/folly
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix IOBuf::reserve() when operating on a user-supplied buffer
Summary: The IOBuf::reserveSlow() code assumed that external buffers were always allocated with malloc. This would cause problems when if reserve() was ever used on a buffer created with IOBuf::takeOwnership(). This changes the code to now check if a user-specified free function has been supplied. If so, then it does not try to use realloc()/rallocm(), and it now frees the old buffer using the specified free function rather than free(). User-supplied buffers also have a separately allocated SharedInfo object, which must be freed when we no longer need it. Test Plan: Added additional unit tests to check calling reserve() on IOBufs created with IOBuf::takeOwnership(). Reviewed By: [email protected] FB internal diff: D1072292
- Loading branch information
Showing
3 changed files
with
62 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters