Use *byte instead of unsafe.Pointer for C bridge methods#12
Draft
Use *byte instead of unsafe.Pointer for C bridge methods#12
Conversation
58a43e4 to
9c8daf3
Compare
c82b0e4 to
d45f7ee
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR updates the C bridge method signatures to use *byte instead of unsafe.Pointer for improved type safety.
- Update cPtrToSlice in native.go to accept a *byte pointer
- Modify cgo_write_buffer and cgo_read_buffer functions to use *byte for their pointer parameters
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/native/native_internal_test.go | Added tests to validate byte conversion functions |
| internal/native/native.go | Updated cPtrToSlice to use *byte and adjusted pointer conversion |
| internal/native/cgo_write.go | Changed cgo_write_buffer parameter type from unsafe.Pointer to *byte |
| internal/native/cgo_read.go | Changed cgo_read_buffer parameter type from unsafe.Pointer to *byte |
Comments suppressed due to low confidence (3)
internal/native/native.go:31
- Ensure that all call sites for cPtrToSlice are updated to provide a *byte instead of an unsafe.Pointer to avoid unexpected runtime behavior.
func cPtrToSlice(ptr *byte, size int) []byte {
internal/native/cgo_write.go:18
- Verify that the corresponding C declarations and any caller conversions are updated to work with *byte rather than unsafe.Pointer.
dataPtr *byte,
internal/native/cgo_read.go:23
- Ensure that the C interface for cgo_read_buffer is modified accordingly to correctly pass a *byte pointer, avoiding potential pointer mismatches.
bufPtr *byte,
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.