zeroshade commented on code in PR #289:
URL: https://github.com/apache/arrow-go/pull/289#discussion_r1965744244


##########
arrow/memory/mallocator/mallocator.go:
##########
@@ -58,28 +70,44 @@ func (alloc *Mallocator) Allocate(size int) []byte {
        if size < 0 {
                panic("mallocator: negative size")
        }
-       ptr, err := C.calloc(C.size_t(size), 1)
+       paddedSize := C.size_t(size) + C.size_t(alloc.alignment)
+       ptr, err := C.calloc(paddedSize, 1)
        if err != nil {
                // under some circumstances and allocation patterns, we can end 
up in a scenario
                // where for some reason calloc return ENOMEM even though there 
is definitely memory
                // available for use. So we attempt to fallback to simply doing 
malloc + memset in
                // this case. If malloc returns a nil pointer, then we know 
we're out of memory
                // and will surface the error.
-               if ptr = C.malloc(C.size_t(size)); ptr == nil {
+               if ptr = C.malloc(paddedSize); ptr == nil {
                        panic(err)
                }
-               C.memset(ptr, 0, C.size_t(size))
+               C.memset(ptr, 0, C.size_t(paddedSize))

Review Comment:
   `paddedSize` is already a `C.size_t` now, so you don't need the cast



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to