Skip to content

Added new developer quality of life extensions.#9

Merged
DeveloprOfThings merged 1 commit intomainfrom
added-new-extension-functions
Mar 18, 2026
Merged

Added new developer quality of life extensions.#9
DeveloprOfThings merged 1 commit intomainfrom
added-new-extension-functions

Conversation

@DeveloprOfThings
Copy link
Owner

  • Added @InternalKapacityApi opt-in annotation to guard internal pr…operties and functions.
  • Introduced rawBytesCoercedToIntRange to safely clamp byte counts to Int.MAX_VALUE - 8 for JVM/Android array and buffer allocations, preventing NegativeArraySizeException and OutOfMemoryError.
  • Added toNSData() and toNSMutableData() extension functions for iOS.
  • Added allocateByteBuffer() and directAllocateByteBuffer() for Android, alongside get and put overloads that accept Kapacity.
  • Enhanced Buffer with skip, readAtMostTo, and write extensions using Kapacity for improved kotlinx-io integration.
  • Added ByteString.substring extension taking a Kapacity parameter with safe bounds clamping.
  • Implemented copyInto extension functions for ByteArray, UByteArray, and generic Array types using Kapacity.
  • Updated Kapacity.fromBytes to enforce a minimum value of 0.
  • Included comprehensive unit tests for new buffer allocation, array copying, and IO operations.
  • Incremented project version to 0.9.9-beta08.

…operties and functions.

- Introduced `rawBytesCoercedToIntRange` to safely clamp byte counts to `Int.MAX_VALUE - 8` for JVM/Android array and buffer allocations, preventing `NegativeArraySizeException` and `OutOfMemoryError`.
- Added `toNSData()` and `toNSMutableData()` extension functions for iOS.
- Added `allocateByteBuffer()` and `directAllocateByteBuffer()` for Android, alongside `get` and `put` overloads that accept `Kapacity`.
- Enhanced `Buffer` with `skip`, `readAtMostTo`, and `write` extensions using `Kapacity` for improved `kotlinx-io` integration.
- Added `ByteString.substring` extension taking a `Kapacity` parameter with safe bounds clamping.
- Implemented `copyInto` extension functions for `ByteArray`, `UByteArray`, and generic `Array` types using `Kapacity`.
- Updated `Kapacity.fromBytes` to enforce a minimum value of 0.
- Included comprehensive unit tests for new buffer allocation, array copying, and IO operations.
- Incremented project version to `0.9.9-beta08`.
@DeveloprOfThings DeveloprOfThings self-assigned this Mar 18, 2026
@DeveloprOfThings DeveloprOfThings merged commit 9556e20 into main Mar 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant