Skip to content

Commit

Permalink
vendored: FIX: Remove std:: before malloc and free to let them be jem…
Browse files Browse the repository at this point in the history
…alloc

Since jemalloc.h does

    #  define malloc je_malloc

when JEMALLOC_MANGLE is defined, I'm getting this error in CI

    /arrow/cpp/src/arrow/vendored/ProducerConsumerQueue.h: In constructor 'arrow_vendored::folly::ProducerConsumerQueue<T>::ProducerConsumerQueue(uint32_t)':

    /arrow/cpp/src/arrow/vendored/ProducerConsumerQueue.h:82:39: error: 'je_arrow_malloc' is not a member of 'std'; did you mean 'je_arrow_malloc'?

       82 |         records_(static_cast<T*>(std::malloc(sizeof(T) * size))),

          |                                       ^~~~~~

    jemalloc_ep-prefix/src/jemalloc_ep/dist/include/jemalloc/jemalloc.h:254:32: note: 'je_arrow_malloc' declared here

      254 |     void JEMALLOC_SYS_NOTHROW *je_malloc(size_t size)

          |                                ^~~~~~~~~

    /arrow/cpp/src/arrow/vendored/ProducerConsumerQueue.h: In destructor 'arrow_vendored::folly::ProducerConsumerQueue<T>::~ProducerConsumerQueue()':

    /arrow/cpp/src/arrow/vendored/ProducerConsumerQueue.h:106:10: error: 'je_arrow_free' is not a member of 'std'; did you mean 'je_arrow_free'?

      106 |     std::free(records_);

          |          ^~~~

    jemalloc_ep-prefix/src/jemalloc_ep/dist/include/jemalloc/jemalloc.h:269:43: note: 'je_arrow_free' declared here

      269 | JEMALLOC_EXPORT void JEMALLOC_SYS_NOTHROW je_free(void *ptr)

          |                                           ^~~~~~~

Removing the std:: prefix fixes this.
  • Loading branch information
felipecrv committed Feb 14, 2023
1 parent c402fc7 commit 94fb574
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cpp/src/arrow/vendored/ProducerConsumerQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct ProducerConsumerQueue {
// IsFull() will return true after size-1 insertions.
explicit ProducerConsumerQueue(uint32_t size)
: size_(size),
records_(static_cast<T*>(std::malloc(sizeof(T) * size))),
records_(static_cast<T*>(malloc(sizeof(T) * size))),
readIndex_(0),
writeIndex_(0) {
assert(size >= 2);
Expand All @@ -103,7 +103,7 @@ struct ProducerConsumerQueue {
}
}

std::free(records_);
free(records_);
}

template <class... Args>
Expand Down

0 comments on commit 94fb574

Please sign in to comment.