@@ -119,15 +119,6 @@ PlasmaStore::PlasmaStore(EventLoop* loop, int64_t system_memory, std::string dir
119
119
120
120
// TODO(pcm): Get rid of this destructor by using RAII to clean up data.
121
121
PlasmaStore::~PlasmaStore () {
122
- for (const auto & element : pending_notifications_) {
123
- auto object_notifications = element.second .object_notifications ;
124
- for (size_t i = 0 ; i < object_notifications.size (); ++i) {
125
- uint8_t * notification = reinterpret_cast <uint8_t *>(object_notifications.at (i));
126
- uint8_t * data = notification;
127
- // TODO(pcm): Get rid of this delete.
128
- delete[] data;
129
- }
130
- }
131
122
}
132
123
133
124
const PlasmaStoreInfo* PlasmaStore::get_plasma_store_info () { return &store_info_; }
@@ -322,11 +313,11 @@ void PlasmaStore::return_from_get(GetRequest* get_req) {
322
313
}
323
314
324
315
void PlasmaStore::update_object_get_requests (const ObjectID& object_id) {
325
- std::vector<GetRequest*> & get_requests = object_get_requests_[object_id];
316
+ auto & get_requests = object_get_requests_[object_id];
326
317
size_t index = 0 ;
327
318
size_t num_requests = get_requests.size ();
328
319
for (size_t i = 0 ; i < num_requests; ++i) {
329
- GetRequest* get_req = get_requests[index ];
320
+ auto get_req = get_requests[index ];
330
321
auto entry = get_object_table_entry (&store_info_, object_id);
331
322
ARROW_CHECK (entry != NULL );
332
323
@@ -356,7 +347,7 @@ void PlasmaStore::process_get_request(Client* client,
356
347
const std::vector<ObjectID>& object_ids,
357
348
int64_t timeout_ms) {
358
349
// Create a get request for this object.
359
- GetRequest* get_req = new GetRequest (client, object_ids);
350
+ auto get_req = new GetRequest (client, object_ids);
360
351
361
352
for (auto object_id : object_ids) {
362
353
// Check if this object is already present locally. If so, record that the
@@ -582,13 +573,12 @@ void PlasmaStore::send_notifications(int client_fd) {
582
573
// Loop over the array of pending notifications and send as many of them as
583
574
// possible.
584
575
for (size_t i = 0 ; i < it->second .object_notifications .size (); ++i) {
585
- uint8_t * notification =
586
- reinterpret_cast <uint8_t *>(it->second .object_notifications .at (i));
576
+ auto & notification = it->second .object_notifications .at (i);
587
577
// Decode the length, which is the first bytes of the message.
588
- int64_t size = *(reinterpret_cast <int64_t *>(notification));
578
+ int64_t size = *(reinterpret_cast <int64_t *>(notification. get () ));
589
579
590
580
// Attempt to send a notification about this object ID.
591
- ssize_t nbytes = send (client_fd, notification, sizeof (int64_t ) + size, 0 );
581
+ ssize_t nbytes = send (client_fd, notification. get () , sizeof (int64_t ) + size, 0 );
592
582
if (nbytes >= 0 ) {
593
583
ARROW_CHECK (nbytes == static_cast <ssize_t >(sizeof (int64_t )) + size);
594
584
} else if (nbytes == -1 &&
@@ -613,9 +603,6 @@ void PlasmaStore::send_notifications(int client_fd) {
613
603
}
614
604
}
615
605
num_processed += 1 ;
616
- // The corresponding malloc happened in create_object_info_buffer
617
- // within push_notification.
618
- delete[] notification;
619
606
}
620
607
// Remove the sent notifications from the array.
621
608
it->second .object_notifications .erase (
@@ -636,8 +623,8 @@ void PlasmaStore::send_notifications(int client_fd) {
636
623
637
624
void PlasmaStore::push_notification (ObjectInfoT* object_info) {
638
625
for (auto & element : pending_notifications_) {
639
- uint8_t * notification = create_object_info_buffer (object_info);
640
- element.second .object_notifications .push_back ( notification);
626
+ auto notification = create_object_info_buffer (object_info);
627
+ element.second .object_notifications .emplace_back ( std::move ( notification) );
641
628
send_notifications (element.first );
642
629
// The notification gets freed in send_notifications when the notification
643
630
// is sent over the socket.
0 commit comments