@@ -111,10 +111,10 @@ struct DHT {
111
111
uint8_t self_public_key [CRYPTO_PUBLIC_KEY_SIZE ];
112
112
uint8_t self_secret_key [CRYPTO_SECRET_KEY_SIZE ];
113
113
114
- DHT_Friend * friends_list ;
114
+ DHT_Friend * owner friends_list ;
115
115
uint16_t num_friends ;
116
116
117
- Node_format * loaded_nodes_list ;
117
+ Node_format * owner loaded_nodes_list ;
118
118
uint32_t loaded_num_nodes ;
119
119
unsigned int loaded_nodes_index ;
120
120
@@ -371,7 +371,7 @@ int dht_create_packet(const Memory *mem, const Random *rng,
371
371
uint8_t * packet , size_t length )
372
372
{
373
373
uint8_t nonce [CRYPTO_NONCE_SIZE ];
374
- uint8_t * encrypted = (uint8_t * )mem_balloc (mem , plain_length + CRYPTO_MAC_SIZE );
374
+ uint8_t * owner encrypted = (uint8_t * owner )mem_balloc (mem , plain_length + CRYPTO_MAC_SIZE );
375
375
376
376
if (encrypted == nullptr ) {
377
377
return -1 ;
@@ -1637,13 +1637,14 @@ int dht_addfriend(DHT *dht, const uint8_t *public_key, dht_ip_cb *ip_callback,
1637
1637
return 0 ;
1638
1638
}
1639
1639
1640
- DHT_Friend * const temp = (DHT_Friend * )mem_vrealloc (dht -> mem , dht -> friends_list , dht -> num_friends + 1 , sizeof (DHT_Friend ));
1640
+ bool ok ;
1641
+ dht -> friends_list =
1642
+ (DHT_Friend * owner )mem_vresize (dht -> mem , dht -> friends_list , dht -> num_friends + 1 , sizeof (DHT_Friend ), & ok );
1641
1643
1642
- if (temp == nullptr ) {
1644
+ if (! ok ) {
1643
1645
return -1 ;
1644
1646
}
1645
1647
1646
- dht -> friends_list = temp ;
1647
1648
DHT_Friend * const dht_friend = & dht -> friends_list [dht -> num_friends ];
1648
1649
* dht_friend = empty_dht_friend ;
1649
1650
memcpy (dht_friend -> public_key , public_key , CRYPTO_PUBLIC_KEY_SIZE );
@@ -1687,13 +1688,14 @@ int dht_delfriend(DHT *dht, const uint8_t *public_key, uint32_t lock_token)
1687
1688
return 0 ;
1688
1689
}
1689
1690
1690
- DHT_Friend * const temp = (DHT_Friend * )mem_vrealloc (dht -> mem , dht -> friends_list , dht -> num_friends , sizeof (DHT_Friend ));
1691
+ bool ok ;
1692
+ dht -> friends_list =
1693
+ (DHT_Friend * owner )mem_vresize (dht -> mem , dht -> friends_list , dht -> num_friends , sizeof (DHT_Friend ), & ok );
1691
1694
1692
- if (temp == nullptr ) {
1695
+ if (! ok ) {
1693
1696
return -1 ;
1694
1697
}
1695
1698
1696
- dht -> friends_list = temp ;
1697
1699
return 0 ;
1698
1700
}
1699
1701
@@ -1740,8 +1742,10 @@ static uint8_t do_ping_and_sendnode_requests(DHT *dht, uint64_t *lastgetnode, co
1740
1742
const uint64_t temp_time = mono_time_get (dht -> mono_time );
1741
1743
1742
1744
uint32_t num_nodes = 0 ;
1743
- Client_data * * client_list = (Client_data * * )mem_valloc (dht -> mem , list_count * 2 , sizeof (Client_data * ));
1744
- IPPTsPng * * assoc_list = (IPPTsPng * * )mem_valloc (dht -> mem , list_count * 2 , sizeof (IPPTsPng * ));
1745
+ Client_data * * owner client_list =
1746
+ (Client_data * * owner )mem_valloc (dht -> mem , list_count * 2 , sizeof (Client_data * ));
1747
+ IPPTsPng * * owner assoc_list =
1748
+ (IPPTsPng * * owner )mem_valloc (dht -> mem , list_count * 2 , sizeof (IPPTsPng * ));
1745
1749
unsigned int sort = 0 ;
1746
1750
bool sort_ok = false;
1747
1751
@@ -2559,15 +2563,16 @@ static int handle_lan_discovery(void *object, const IP_Port *source, const uint8
2559
2563
2560
2564
/*----------------------------------------------------------------------------------*/
2561
2565
2562
- DHT * new_dht (const Logger * log , const Memory * mem , const Random * rng , const Network * ns ,
2563
- Mono_Time * mono_time , Networking_Core * net ,
2564
- bool hole_punching_enabled , bool lan_discovery_enabled )
2566
+ DHT * owner new_dht (
2567
+ const Logger * log , const Memory * mem , const Random * rng , const Network * ns ,
2568
+ Mono_Time * mono_time , Networking_Core * net ,
2569
+ bool hole_punching_enabled , bool lan_discovery_enabled )
2565
2570
{
2566
2571
if (net == nullptr ) {
2567
2572
return nullptr ;
2568
2573
}
2569
2574
2570
- DHT * const dht = (DHT * )mem_alloc (mem , sizeof (DHT ));
2575
+ DHT * const owner dht = (DHT * owner )mem_alloc (mem , sizeof (DHT ));
2571
2576
2572
2577
if (dht == nullptr ) {
2573
2578
LOGGER_ERROR (log , "failed to allocate DHT struct (%ld bytes)" , (unsigned long )sizeof (DHT ));
@@ -2666,7 +2671,7 @@ void do_dht(DHT *dht)
2666
2671
ping_iterate (dht -> ping );
2667
2672
}
2668
2673
2669
- void kill_dht (DHT * dht )
2674
+ void kill_dht (DHT * owner dht )
2670
2675
{
2671
2676
if (dht == nullptr ) {
2672
2677
return ;
@@ -2739,7 +2744,8 @@ void dht_save(const DHT *dht, uint8_t *data)
2739
2744
/* get right offset. we write the actual header later. */
2740
2745
data = state_write_section_header (data , DHT_STATE_COOKIE_TYPE , 0 , 0 );
2741
2746
2742
- Node_format * clients = (Node_format * )mem_valloc (dht -> mem , MAX_SAVED_DHT_NODES , sizeof (Node_format ));
2747
+ Node_format * owner clients =
2748
+ (Node_format * owner )mem_valloc (dht -> mem , MAX_SAVED_DHT_NODES , sizeof (Node_format ));
2743
2749
2744
2750
if (clients == nullptr ) {
2745
2751
LOGGER_ERROR (dht -> log , "could not allocate %u nodes" , MAX_SAVED_DHT_NODES );
@@ -2836,7 +2842,8 @@ static State_Load_Status dht_load_state_callback(void *outer, const uint8_t *dat
2836
2842
mem_delete (dht -> mem , dht -> loaded_nodes_list );
2837
2843
2838
2844
// Copy to loaded_clients_list
2839
- Node_format * nodes = (Node_format * )mem_valloc (dht -> mem , MAX_SAVED_DHT_NODES , sizeof (Node_format ));
2845
+ Node_format * owner nodes =
2846
+ (Node_format * owner )mem_valloc (dht -> mem , MAX_SAVED_DHT_NODES , sizeof (Node_format ));
2840
2847
2841
2848
if (nodes == nullptr ) {
2842
2849
LOGGER_ERROR (dht -> log , "could not allocate %u nodes" , MAX_SAVED_DHT_NODES );
0 commit comments