The following commit has been merged in the master branch:
commit 3786437e29f1103a40163316137d0338efdd98c5
Author: Marek Lindner <lindner_marek(a)yahoo.de>
Date: Fri Mar 9 13:36:00 2007 +0100
debugMalloc / debugFree renumbering
diff --git a/batman.c b/batman.c
index ed6a7eb..c853253 100644
--- a/batman.c
+++ b/batman.c
@@ -194,7 +194,7 @@ struct orig_node *get_orig_node( uint32_t addr ) {
debug_output( 4, "Creating new originator\n" );
- orig_node = debugMalloc( sizeof(struct orig_node), 1 );
+ orig_node = debugMalloc( sizeof(struct orig_node), 101 );
memset(orig_node, 0, sizeof(struct orig_node));
INIT_LIST_HEAD(&orig_node->list);
INIT_LIST_HEAD(&orig_node->neigh_list);
@@ -202,7 +202,7 @@ struct orig_node *get_orig_node( uint32_t addr ) {
orig_node->orig = addr;
orig_node->router = NULL;
- orig_node->bidirect_link = debugMalloc( found_ifs * sizeof(uint32_t), 2 );
+ orig_node->bidirect_link = debugMalloc( found_ifs * sizeof(uint32_t), 102 );
memset( orig_node->bidirect_link, 0, found_ifs * sizeof(uint32_t) );
list_add_tail( &orig_node->list, &orig_list );
@@ -233,7 +233,7 @@ void add_del_hna( struct orig_node *orig_node, int8_t del ) {
if ( del ) {
- debugFree( orig_node->hna_buff, 101 );
+ debugFree( orig_node->hna_buff, 1101 );
orig_node->hna_buff_len = 0;
}
@@ -403,7 +403,7 @@ static void update_routes( struct orig_node *orig_node, struct neigh_node *neigh
/* add new announced network(s) */
if ( hna_buff_len > 0 ) {
- orig_node->hna_buff = debugMalloc( hna_buff_len, 3 );
+ orig_node->hna_buff = debugMalloc( hna_buff_len, 103 );
orig_node->hna_buff_len = hna_buff_len;
memmove( orig_node->hna_buff, hna_recv_buff, hna_buff_len );
@@ -426,7 +426,7 @@ static void update_routes( struct orig_node *orig_node, struct neigh_node *neigh
if ( hna_buff_len > 0 ) {
- orig_node->hna_buff = debugMalloc( hna_buff_len, 4 );
+ orig_node->hna_buff = debugMalloc( hna_buff_len, 104 );
orig_node->hna_buff_len = hna_buff_len;
memcpy( orig_node->hna_buff, hna_recv_buff, hna_buff_len );
@@ -481,7 +481,7 @@ static void update_gw_list( struct orig_node *orig_node, uint8_t new_gwflags ) {
addr_to_string( orig_node->orig, orig_str, ADDR_STR_LEN );
debug_output( 3, "Found new gateway %s -> class: %i - %s\n", orig_str, new_gwflags, gw2string[new_gwflags] );
- gw_node = debugMalloc( sizeof(struct gw_node), 5 );
+ gw_node = debugMalloc( sizeof(struct gw_node), 105 );
memset( gw_node, 0, sizeof(struct gw_node) );
INIT_LIST_HEAD( &gw_node->list );
@@ -685,7 +685,7 @@ void update_originator( struct orig_node *orig_node, struct packet *in, uint32_t
debug_output( 4, "Creating new last-hop neighbour of originator\n" );
- neigh_node = debugMalloc( sizeof (struct neigh_node), 6 );
+ neigh_node = debugMalloc( sizeof (struct neigh_node), 106 );
memset( neigh_node, 0, sizeof(struct neigh_node) );
INIT_LIST_HEAD( &neigh_node->list );
@@ -741,7 +741,7 @@ void schedule_own_packet( struct batman_if *batman_if ) {
struct list_head *list_pos;
- forw_node_new = debugMalloc( sizeof(struct forw_node), 11 );
+ forw_node_new = debugMalloc( sizeof(struct forw_node), 107 );
INIT_LIST_HEAD( &forw_node_new->list );
@@ -751,14 +751,14 @@ void schedule_own_packet( struct batman_if *batman_if ) {
if ( num_hna > 0 ) {
- forw_node_new->pack_buff = debugMalloc( sizeof(struct packet) + num_hna * 5 * sizeof(unsigned char), 12 );
+ forw_node_new->pack_buff = debugMalloc( sizeof(struct packet) + num_hna * 5 * sizeof(unsigned char), 108 );
memcpy( forw_node_new->pack_buff, (unsigned char *)&batman_if->out, sizeof(struct packet) );
memcpy( forw_node_new->pack_buff + sizeof(struct packet), hna_buff, num_hna * 5 * sizeof(unsigned char) );
forw_node_new->pack_buff_len = sizeof(struct packet) + num_hna * 5 * sizeof(unsigned char);
} else {
- forw_node_new->pack_buff = debugMalloc( sizeof(struct packet), 13 );
+ forw_node_new->pack_buff = debugMalloc( sizeof(struct packet), 109 );
memcpy( forw_node_new->pack_buff, &batman_if->out, sizeof(struct packet) );
forw_node_new->pack_buff_len = sizeof(struct packet);
@@ -798,20 +798,20 @@ void schedule_forward_packet( struct packet *in, uint8_t unidirectional, uint8_t
} else {
- forw_node_new = debugMalloc( sizeof(struct forw_node), 8 );
+ forw_node_new = debugMalloc( sizeof(struct forw_node), 110 );
INIT_LIST_HEAD(&forw_node_new->list);
if ( hna_buff_len > 0 ) {
- forw_node_new->pack_buff = debugMalloc( sizeof(struct packet) + hna_buff_len, 9 );
+ forw_node_new->pack_buff = debugMalloc( sizeof(struct packet) + hna_buff_len, 111 );
memcpy( forw_node_new->pack_buff, in, sizeof(struct packet) );
memcpy( forw_node_new->pack_buff + sizeof(struct packet), hna_recv_buff, hna_buff_len );
forw_node_new->pack_buff_len = sizeof(struct packet) + hna_buff_len;
} else {
- forw_node_new->pack_buff = debugMalloc( sizeof(struct packet), 10 );
+ forw_node_new->pack_buff = debugMalloc( sizeof(struct packet), 112 );
memcpy( forw_node_new->pack_buff, in, sizeof(struct packet) );
forw_node_new->pack_buff_len = sizeof(struct packet);
@@ -950,8 +950,8 @@ void send_outstanding_packets() {
if ( forw_node->own )
schedule_own_packet( forw_node->if_outgoing );
- debugFree( forw_node->pack_buff, 103 );
- debugFree( forw_node, 104 );
+ debugFree( forw_node->pack_buff, 1102 );
+ debugFree( forw_node, 1103 );
} else {
@@ -992,7 +992,7 @@ void purge( uint32_t curr_time ) {
neigh_node = list_entry(neigh_pos, struct neigh_node, list);
list_del( neigh_pos );
- debugFree( neigh_node, 107 );
+ debugFree( neigh_node, 1104 );
}
@@ -1022,8 +1022,8 @@ void purge( uint32_t curr_time ) {
update_routes( orig_node, NULL, NULL, 0 );
- debugFree( orig_node->bidirect_link, 109 );
- debugFree( orig_node, 110 );
+ debugFree( orig_node->bidirect_link, 1105 );
+ debugFree( orig_node, 1106 );
} else {
@@ -1035,7 +1035,7 @@ void purge( uint32_t curr_time ) {
if ( (int)( ( neigh_node->last_aware + ( 2 * TIMEOUT ) ) < curr_time ) ) {
list_del( neigh_pos );
- debugFree( neigh_node, 108 );
+ debugFree( neigh_node, 1107 );
}
@@ -1052,7 +1052,7 @@ void purge( uint32_t curr_time ) {
if ( ( gw_node->deleted ) && ( (int)((gw_node->deleted + 3 * TIMEOUT) < curr_time) ) ) {
list_del( gw_pos );
- debugFree( gw_pos, 107 );
+ debugFree( gw_pos, 1108 );
}
@@ -1090,7 +1090,7 @@ void send_vis_packet()
if(packet != NULL)
{
send_packet(packet, size * sizeof(unsigned char), &vis_if.addr, vis_if.sock);
- debugFree( packet, 111 );
+ debugFree( packet, 1109 );
}
}
@@ -1414,12 +1414,12 @@ int8_t batman() {
hna_node = list_entry(hna_pos, struct hna_node, list);
- debugFree( hna_node, 114 );
+ debugFree( hna_node, 1110 );
}
if ( hna_buff != NULL )
- debugFree( hna_buff, 115 );
+ debugFree( hna_buff, 1111 );
list_for_each_safe( forw_pos, forw_pos_tmp, &forw_list ) {
@@ -1427,8 +1427,8 @@ int8_t batman() {
list_del( forw_pos );
- debugFree( forw_node->pack_buff, 112 );
- debugFree( forw_node, 113 );
+ debugFree( forw_node->pack_buff, 1112 );
+ debugFree( forw_node, 1113 );
}
diff --git a/posix-specific.c b/posix-specific.c
index e6eb129..f8d4695 100644
--- a/posix-specific.c
+++ b/posix-specific.c
@@ -144,7 +144,7 @@ void *unix_listen( void *arg ) {
/* new client */
if ( FD_ISSET( unix_if.unix_sock, &tmp_wait_sockets ) ) {
- unix_client = debugMalloc( sizeof(struct unix_client), 133 );
+ unix_client = debugMalloc( sizeof(struct unix_client), 201 );
memset( unix_client, 0, sizeof(struct unix_client) );
if ( ( unix_client->sock = accept( unix_if.unix_sock, (struct sockaddr *)&unix_client->addr, &sun_size) ) == -1 ) {
@@ -195,7 +195,7 @@ void *unix_listen( void *arg ) {
list_del( debug_pos );
debug_clients.clients_num[(int)unix_client->debug_level - '1']--;
- debugFree( debug_pos, 263 );
+ debugFree( debug_pos, 1201 );
break;
@@ -207,7 +207,7 @@ void *unix_listen( void *arg ) {
if ( unix_client->debug_level != buff[2] ) {
- debug_level_info = debugMalloc( sizeof(struct debug_level_info), 57 );
+ debug_level_info = debugMalloc( sizeof(struct debug_level_info), 202 );
INIT_LIST_HEAD( &debug_level_info->list );
debug_level_info->fd = unix_client->sock;
list_add( &debug_level_info->list, (struct list_head *)debug_clients.fd_list[(int)buff[2] - '1'] );
@@ -242,7 +242,7 @@ void *unix_listen( void *arg ) {
list_del( debug_pos );
debug_clients.clients_num[(int)unix_client->debug_level - '1']--;
- debugFree( debug_pos, 264 );
+ debugFree( debug_pos, 1202 );
break;
@@ -260,7 +260,7 @@ void *unix_listen( void *arg ) {
close( unix_client->sock );
list_del( unix_pos );
- debugFree( unix_pos, 231 );
+ debugFree( unix_pos, 1203 );
}
@@ -299,7 +299,7 @@ void *unix_listen( void *arg ) {
list_del( debug_pos );
debug_clients.clients_num[(int)unix_client->debug_level - '1']--;
- debugFree( debug_pos, 265 );
+ debugFree( debug_pos, 1204 );
break;
@@ -310,7 +310,7 @@ void *unix_listen( void *arg ) {
}
list_del( unix_pos );
- debugFree( unix_pos, 241 );
+ debugFree( unix_pos, 1205 );
}
@@ -380,7 +380,7 @@ void apply_init_args( int argc, char *argv[] ) {
}
- hna_node = debugMalloc( sizeof(struct hna_node), 16 );
+ hna_node = debugMalloc( sizeof(struct hna_node), 203 );
memset( hna_node, 0, sizeof(struct hna_node) );
INIT_LIST_HEAD( &hna_node->list );
@@ -558,7 +558,7 @@ void apply_init_args( int argc, char *argv[] ) {
for ( res = 0; res < 4; res++ ) {
- debug_clients.fd_list[res] = debugMalloc( sizeof(struct list_head), 97 );
+ debug_clients.fd_list[res] = debugMalloc( sizeof(struct list_head), 204 );
INIT_LIST_HEAD( (struct list_head *)debug_clients.fd_list[res] );
}
@@ -583,7 +583,7 @@ void apply_init_args( int argc, char *argv[] ) {
printf( "B.A.T.M.A.N.-III v%s (compability version %i)\n", SOURCE_VERSION, COMPAT_VERSION );
debug_clients.clients_num[ debug_level - 1 ]++;
- debug_level_info = debugMalloc( sizeof(struct debug_level_info), 39 );
+ debug_level_info = debugMalloc( sizeof(struct debug_level_info), 205 );
INIT_LIST_HEAD( &debug_level_info->list );
debug_level_info->fd = 1;
list_add( &debug_level_info->list, (struct list_head *)debug_clients.fd_list[debug_level - 1] );
@@ -594,7 +594,7 @@ void apply_init_args( int argc, char *argv[] ) {
while ( argc > found_args ) {
- batman_if = debugMalloc( sizeof(struct batman_if), 17 );
+ batman_if = debugMalloc( sizeof(struct batman_if), 206 );
memset( batman_if, 0, sizeof(struct batman_if) );
INIT_LIST_HEAD( &batman_if->list );
INIT_LIST_HEAD( &batman_if->client_list );
@@ -1028,7 +1028,7 @@ void *client_to_gw_tun( void *arg ) {
debug_output( 0, "Error - can't create tcp socket: %s\n", strerror(errno) );
curr_gateway = NULL;
- debugFree( arg, 248 );
+ debugFree( arg, 1206 );
return NULL;
}
@@ -1042,7 +1042,7 @@ void *client_to_gw_tun( void *arg ) {
curr_gw_data->gw_node->unavail_factor++;
curr_gateway = NULL;
- debugFree( arg, 248 );
+ debugFree( arg, 1207 );
return NULL;
}
@@ -1056,7 +1056,7 @@ void *client_to_gw_tun( void *arg ) {
debug_output( 0, "Error - can't create udp socket: %s\n", strerror(errno) );
close( curr_gateway_tcp_sock );
curr_gateway = NULL;
- debugFree( arg, 248 );
+ debugFree( arg, 1208 );
return NULL;
}
@@ -1067,7 +1067,7 @@ void *client_to_gw_tun( void *arg ) {
close( curr_gateway_tcp_sock );
close( curr_gateway_tun_sock );
curr_gateway = NULL;
- debugFree( arg, 248 );
+ debugFree( arg, 1209 );
return NULL;
}
@@ -1082,7 +1082,7 @@ void *client_to_gw_tun( void *arg ) {
close( curr_gateway_tcp_sock );
close( curr_gateway_tun_sock );
curr_gateway = NULL;
- debugFree( arg, 248 );
+ debugFree( arg, 1210 );
return NULL;
}
@@ -1206,7 +1206,7 @@ void *client_to_gw_tun( void *arg ) {
del_dev_tun( curr_gateway_tun_fd );
curr_gateway = NULL;
- debugFree( arg, 248 );
+ debugFree( arg, 1211 );
return NULL;
@@ -1229,7 +1229,7 @@ int8_t add_default_route() {
struct curr_gw_data *curr_gw_data;
- curr_gw_data = debugMalloc( sizeof(struct curr_gw_data), 47 );
+ curr_gw_data = debugMalloc( sizeof(struct curr_gw_data), 207 );
curr_gw_data->orig = curr_gateway->orig_node->orig;
curr_gw_data->gw_node = curr_gateway;
curr_gw_data->batman_if = curr_gateway->orig_node->batman_if;
@@ -1238,7 +1238,7 @@ int8_t add_default_route() {
if ( pthread_create( &curr_gateway_thread_id, NULL, &client_to_gw_tun, curr_gw_data ) != 0 ) {
debug_output( 0, "Error - couldn't spawn thread: %s\n", strerror(errno) );
- debugFree( curr_gw_data, 247 );
+ debugFree( curr_gw_data, 1212 );
curr_gateway = NULL;
}
@@ -1269,7 +1269,7 @@ void close_all_sockets() {
close( batman_if->udp_send_sock );
list_del( if_pos );
- debugFree( if_pos, 203 );
+ debugFree( if_pos, 1213 );
}
@@ -1444,7 +1444,7 @@ void *gw_listen( void *arg ) {
/* new client */
if ( FD_ISSET( batman_if->tcp_gw_sock, &tmp_wait_sockets ) ) {
- gw_client = debugMalloc( sizeof(struct gw_client), 18 );
+ gw_client = debugMalloc( sizeof(struct gw_client), 208 );
memset( gw_client, 0, sizeof(struct gw_client) );
if ( ( gw_client->sock = accept(batman_if->tcp_gw_sock, (struct sockaddr *)&gw_client->addr, &sin_size) ) == -1 ) {
@@ -1541,7 +1541,7 @@ void *gw_listen( void *arg ) {
close( gw_client->sock );
list_del( client_pos );
- debugFree( client_pos, 201 );
+ debugFree( client_pos, 1214 );
}
@@ -1584,7 +1584,7 @@ void *gw_listen( void *arg ) {
debug_output( 3, "gateway: client %s timeout on interface %s\n", str2, batman_if->dev );
list_del( client_pos );
- debugFree( client_pos, 202 );
+ debugFree( client_pos, 1215 );
} else {
@@ -1607,7 +1607,7 @@ void *gw_listen( void *arg ) {
gw_client = list_entry(client_pos, struct gw_client, list);
list_del( client_pos );
- debugFree( client_pos, 297 );
+ debugFree( client_pos, 1216 );
}
@@ -1633,13 +1633,13 @@ void cleanup() {
debug_level_info = list_entry(debug_pos, struct debug_level_info, list);
list_del( debug_pos );
- debugFree( debug_pos, 277 );
+ debugFree( debug_pos, 1217 );
}
}
- debugFree( debug_clients.fd_list[i], 258 );
+ debugFree( debug_clients.fd_list[i], 1218 );
}
--
batman; test conversation