@@ -111,10 +111,10 @@ struct DHT {
111111 uint8_t self_public_key [CRYPTO_PUBLIC_KEY_SIZE ];
112112 uint8_t self_secret_key [CRYPTO_SECRET_KEY_SIZE ];
113113
114- DHT_Friend * friends_list ;
114+ DHT_Friend * owner friends_list ;
115115 uint16_t num_friends ;
116116
117- Node_format * loaded_nodes_list ;
117+ Node_format * owner loaded_nodes_list ;
118118 uint32_t loaded_num_nodes ;
119119 unsigned int loaded_nodes_index ;
120120
@@ -371,7 +371,7 @@ int dht_create_packet(const Memory *mem, const Random *rng,
371371 uint8_t * packet , size_t length )
372372{
373373 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 );
375375
376376 if (encrypted == nullptr ) {
377377 return -1 ;
@@ -1637,13 +1637,14 @@ int dht_addfriend(DHT *dht, const uint8_t *public_key, dht_ip_cb *ip_callback,
16371637 return 0 ;
16381638 }
16391639
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 );
16411643
1642- if (temp == nullptr ) {
1644+ if (! ok ) {
16431645 return -1 ;
16441646 }
16451647
1646- dht -> friends_list = temp ;
16471648 DHT_Friend * const dht_friend = & dht -> friends_list [dht -> num_friends ];
16481649 * dht_friend = empty_dht_friend ;
16491650 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)
16871688 return 0 ;
16881689 }
16891690
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 );
16911694
1692- if (temp == nullptr ) {
1695+ if (! ok ) {
16931696 return -1 ;
16941697 }
16951698
1696- dht -> friends_list = temp ;
16971699 return 0 ;
16981700}
16991701
@@ -1740,8 +1742,10 @@ static uint8_t do_ping_and_sendnode_requests(DHT *dht, uint64_t *lastgetnode, co
17401742 const uint64_t temp_time = mono_time_get (dht -> mono_time );
17411743
17421744 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 * ));
17451749 unsigned int sort = 0 ;
17461750 bool sort_ok = false;
17471751
@@ -2559,15 +2563,16 @@ static int handle_lan_discovery(void *object, const IP_Port *source, const uint8
25592563
25602564/*----------------------------------------------------------------------------------*/
25612565
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 )
25652570{
25662571 if (net == nullptr ) {
25672572 return nullptr ;
25682573 }
25692574
2570- DHT * const dht = (DHT * )mem_alloc (mem , sizeof (DHT ));
2575+ DHT * const owner dht = (DHT * owner )mem_alloc (mem , sizeof (DHT ));
25712576
25722577 if (dht == nullptr ) {
25732578 LOGGER_ERROR (log , "failed to allocate DHT struct (%ld bytes)" , (unsigned long )sizeof (DHT ));
@@ -2666,7 +2671,7 @@ void do_dht(DHT *dht)
26662671 ping_iterate (dht -> ping );
26672672}
26682673
2669- void kill_dht (DHT * dht )
2674+ void kill_dht (DHT * owner dht )
26702675{
26712676 if (dht == nullptr ) {
26722677 return ;
@@ -2739,7 +2744,8 @@ void dht_save(const DHT *dht, uint8_t *data)
27392744 /* get right offset. we write the actual header later. */
27402745 data = state_write_section_header (data , DHT_STATE_COOKIE_TYPE , 0 , 0 );
27412746
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 ));
27432749
27442750 if (clients == nullptr ) {
27452751 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
28362842 mem_delete (dht -> mem , dht -> loaded_nodes_list );
28372843
28382844 // 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 ));
28402847
28412848 if (nodes == nullptr ) {
28422849 LOGGER_ERROR (dht -> log , "could not allocate %u nodes" , MAX_SAVED_DHT_NODES );
0 commit comments