Commit 52b3c76 1 parent 113e650 commit 52b3c76 Copy full SHA for 52b3c76
File tree 2 files changed +23
-0
lines changed
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -291,8 +291,17 @@ class MyMemoryPool : public MemoryPool {
291
291
}
292
292
293
293
void Free (uint8_t * buffer, int64_t size) override { std::free (buffer); }
294
+
294
295
Status Reallocate (int64_t old_size, int64_t new_size, uint8_t ** ptr) override {
295
296
*ptr = reinterpret_cast <uint8_t *>(std::realloc (*ptr, new_size));
297
+
298
+ if (*ptr == NULL ) {
299
+ std::stringstream ss;
300
+ ss << " realloc of size " << new_size << " failed" ;
301
+ return Status::OutOfMemory (ss.str ());
302
+ }
303
+
304
+
296
305
return Status::OK ();
297
306
}
298
307
Original file line number Diff line number Diff line change @@ -47,6 +47,20 @@ class PyArrowMemoryPool : public arrow::MemoryPool {
47
47
return Status::OK ();
48
48
}
49
49
50
+ Status Reallocate (int64_t old_size, int64_t new_size, uint8_t ** ptr) override {
51
+ *ptr = reinterpret_cast <uint8_t *>(std::realloc (*ptr, new_size));
52
+
53
+ if (*ptr == NULL ) {
54
+ std::stringstream ss;
55
+ ss << " realloc of size " << new_size << " failed" ;
56
+ return Status::OutOfMemory (ss.str ());
57
+ }
58
+
59
+ bytes_allocated_ += new_size - old_size;
60
+
61
+ return Status::OK ();
62
+ }
63
+
50
64
int64_t bytes_allocated () const override {
51
65
std::lock_guard<std::mutex> guard (pool_lock_);
52
66
return bytes_allocated_;
You can’t perform that action at this time.
0 commit comments