Changeset 93ebe4e in mainline
- Timestamp:
- 2011-03-29T19:04:41Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3317724, 99b65d2, d011038, ebebd38
- Parents:
- 2afc54d (diff), 5fe7692 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/net/packet.c
r2afc54d r93ebe4e 190 190 } 191 191 } 192 gpm_destroy(&pm_globals.packet_map );192 gpm_destroy(&pm_globals.packet_map, free); 193 193 /* leave locked */ 194 194 } -
uspace/lib/c/generic/net/socket_client.c
r2afc54d r93ebe4e 749 749 dyn_fifo_destroy(&socket->received); 750 750 dyn_fifo_destroy(&socket->accepted); 751 sockets_exclude(socket_get_sockets(), socket->socket_id );751 sockets_exclude(socket_get_sockets(), socket->socket_id, free); 752 752 } 753 753 -
uspace/lib/c/include/adt/generic_char_map.h
r2afc54d r93ebe4e 47 47 #define GENERIC_CHAR_MAP_MAGIC_VALUE 0x12345622 48 48 49 /** Generic destructor function pointer. */ 50 #define DTOR_T(identifier) \ 51 void (*identifier)(const void *) 52 49 53 /** Character string to generic type map declaration. 50 54 * @param[in] name Name of the map. … … 64 68 int name##_add(name##_t *, const uint8_t *, const size_t, type *); \ 65 69 int name##_count(name##_t *); \ 66 void name##_destroy(name##_t * ); \67 void name##_exclude(name##_t *, const uint8_t *, const size_t ); \70 void name##_destroy(name##_t *, DTOR_T()); \ 71 void name##_exclude(name##_t *, const uint8_t *, const size_t, DTOR_T()); \ 68 72 type *name##_find(name##_t *, const uint8_t *, const size_t); \ 69 73 int name##_initialize(name##_t *); \ … … 84 88 type *value) \ 85 89 { \ 86 int rc; \87 90 int index; \ 88 91 if (!name##_is_valid(map)) \ … … 91 94 if (index < 0) \ 92 95 return index; \ 93 rc = char_map_add(&map->names, name, length, index); \ 94 if (rc != EOK) { \ 95 name##_items_exclude_index(&map->values, index); \ 96 return rc; \ 97 } \ 98 return EOK; \ 96 return char_map_add(&map->names, name, length, index); \ 99 97 } \ 100 98 \ … … 105 103 } \ 106 104 \ 107 void name##_destroy(name##_t *map ) \105 void name##_destroy(name##_t *map, DTOR_T(dtor)) \ 108 106 { \ 109 107 if (name##_is_valid(map)) { \ 110 108 char_map_destroy(&map->names); \ 111 name##_items_destroy(&map->values ); \109 name##_items_destroy(&map->values, dtor); \ 112 110 } \ 113 111 } \ 114 112 \ 115 113 void name##_exclude(name##_t *map, const uint8_t *name, \ 116 const size_t length ) \114 const size_t length, DTOR_T(dtor)) \ 117 115 { \ 118 116 if (name##_is_valid(map)) { \ … … 121 119 if (index != CHAR_MAP_NULL) \ 122 120 name##_items_exclude_index(&map->values, \ 123 index ); \121 index, dtor); \ 124 122 } \ 125 123 } \ -
uspace/lib/c/include/adt/generic_field.h
r2afc54d r93ebe4e 46 46 #define GENERIC_FIELD_MAGIC_VALUE 0x55667788 47 47 48 /** Generic destructor function pointer. */ 49 #define DTOR_T(identifier) \ 50 void (*identifier)(const void *) 51 48 52 /** Generic type field declaration. 49 53 * … … 63 67 int name##_add(name##_t *, type *); \ 64 68 int name##_count(name##_t *); \ 65 void name##_destroy(name##_t * ); \66 void name##_exclude_index(name##_t *, int ); \69 void name##_destroy(name##_t *, DTOR_T()); \ 70 void name##_exclude_index(name##_t *, int, DTOR_T()); \ 67 71 type **name##_get_field(name##_t *); \ 68 72 type *name##_get_index(name##_t *, int); \ … … 103 107 } \ 104 108 \ 105 void name##_destroy(name##_t *field ) \109 void name##_destroy(name##_t *field, DTOR_T(dtor)) \ 106 110 { \ 107 111 if (name##_is_valid(field)) { \ 108 112 int index; \ 109 113 field->magic = 0; \ 110 for (index = 0; index < field->next; index++) { \ 111 if (field->items[index]) \ 112 free(field->items[index]); \ 114 if (dtor) { \ 115 for (index = 0; index < field->next; index++) { \ 116 if (field->items[index]) \ 117 dtor(field->items[index]); \ 118 } \ 113 119 } \ 114 120 free(field->items); \ … … 116 122 } \ 117 123 \ 118 void name##_exclude_index(name##_t *field, int index ) \124 void name##_exclude_index(name##_t *field, int index, DTOR_T(dtor)) \ 119 125 { \ 120 126 if (name##_is_valid(field) && (index >= 0) && \ 121 127 (index < field->next) && (field->items[index])) { \ 122 free(field->items[index]); \ 128 if (dtor) \ 129 dtor(field->items[index]); \ 123 130 field->items[index] = NULL; \ 124 131 } \ -
uspace/lib/c/include/adt/int_map.h
r2afc54d r93ebe4e 49 49 #define INT_MAP_ITEM_MAGIC_VALUE 0x55667788 50 50 51 /** Generic destructor function pointer. */ 52 #define DTOR_T(identifier) \ 53 void (*identifier)(const void *) 54 51 55 /** Integer to generic type map declaration. 52 56 * … … 72 76 \ 73 77 int name##_add(name##_t *, int, type *); \ 74 void name##_clear(name##_t * ); \78 void name##_clear(name##_t *, DTOR_T()); \ 75 79 int name##_count(name##_t *); \ 76 void name##_destroy(name##_t * ); \77 void name##_exclude(name##_t *, int ); \78 void name##_exclude_index(name##_t *, int ); \80 void name##_destroy(name##_t *, DTOR_T()); \ 81 void name##_exclude(name##_t *, int, DTOR_T()); \ 82 void name##_exclude_index(name##_t *, int, DTOR_T()); \ 79 83 type *name##_find(name##_t *, int); \ 80 84 int name##_update(name##_t *, int, int); \ … … 82 86 int name##_initialize(name##_t *); \ 83 87 int name##_is_valid(name##_t *); \ 84 void name##_item_destroy(name##_item_t * ); \88 void name##_item_destroy(name##_item_t *, DTOR_T()); \ 85 89 int name##_item_is_valid(name##_item_t *); 86 90 … … 115 119 } \ 116 120 \ 117 void name##_clear(name##_t *map ) \121 void name##_clear(name##_t *map, DTOR_T(dtor)) \ 118 122 { \ 119 123 if (name##_is_valid(map)) { \ … … 122 126 if (name##_item_is_valid(&map->items[index])) { \ 123 127 name##_item_destroy( \ 124 &map->items[index] ); \128 &map->items[index], dtor); \ 125 129 } \ 126 130 } \ … … 135 139 } \ 136 140 \ 137 void name##_destroy(name##_t *map ) \141 void name##_destroy(name##_t *map, DTOR_T(dtor)) \ 138 142 { \ 139 143 if (name##_is_valid(map)) { \ … … 143 147 if (name##_item_is_valid(&map->items[index])) { \ 144 148 name##_item_destroy( \ 145 &map->items[index] ); \149 &map->items[index], dtor); \ 146 150 } \ 147 151 } \ … … 150 154 } \ 151 155 \ 152 void name##_exclude(name##_t *map, int key ) \156 void name##_exclude(name##_t *map, int key, DTOR_T(dtor)) \ 153 157 { \ 154 158 if (name##_is_valid(map)) { \ … … 158 162 (map->items[index].key == key)) { \ 159 163 name##_item_destroy( \ 160 &map->items[index] ); \161 } \ 162 } \ 163 } \ 164 } \ 165 \ 166 void name##_exclude_index(name##_t *map, int index ) \164 &map->items[index], dtor); \ 165 } \ 166 } \ 167 } \ 168 } \ 169 \ 170 void name##_exclude_index(name##_t *map, int index, DTOR_T(dtor)) \ 167 171 { \ 168 172 if (name##_is_valid(map) && (index >= 0) && \ 169 173 (index < map->next) && \ 170 174 name##_item_is_valid(&map->items[index])) { \ 171 name##_item_destroy(&map->items[index] ); \175 name##_item_destroy(&map->items[index], dtor); \ 172 176 } \ 173 177 } \ … … 236 240 } \ 237 241 \ 238 void name##_item_destroy(name##_item_t *item ) \242 void name##_item_destroy(name##_item_t *item, DTOR_T(dtor)) \ 239 243 { \ 240 244 if (name##_item_is_valid(item)) { \ 241 245 item->magic = 0; \ 242 246 if (item->value) { \ 243 free(item->value); \ 247 if (dtor) \ 248 dtor(item->value); \ 244 249 item->value = NULL; \ 245 250 } \ -
uspace/lib/net/tl/socket_core.c
r2afc54d r93ebe4e 107 107 socket_release(socket); 108 108 109 socket_cores_exclude(local_sockets, socket->socket_id );109 socket_cores_exclude(local_sockets, socket->socket_id, free); 110 110 } 111 111 … … 230 230 231 231 fail: 232 socket_port_map_destroy(&socket_port->map );232 socket_port_map_destroy(&socket_port->map, free); 233 233 free(socket_port); 234 234 return rc; … … 649 649 if (socket_port->count <= 0) { 650 650 // destroy the map 651 socket_port_map_destroy(&socket_port->map );651 socket_port_map_destroy(&socket_port->map, free); 652 652 // release the port 653 653 socket_ports_exclude(global_sockets, 654 socket->port );654 socket->port, free); 655 655 } else { 656 656 // remove 657 657 socket_port_map_exclude(&socket_port->map, 658 socket->key, socket->key_length );658 socket->key, socket->key_length, free); 659 659 } 660 660 } -
uspace/lib/net/tl/tl_common.c
r2afc54d r93ebe4e 182 182 else 183 183 packet_dimensions_exclude(packet_dimensions, 184 DEVICE_INVALID_ID );184 DEVICE_INVALID_ID, free); 185 185 } 186 186 } -
uspace/srv/net/il/arp/arp.c
r2afc54d r93ebe4e 157 157 158 158 arp_clear_addr(&proto->addresses); 159 arp_addr_destroy(&proto->addresses );160 } 161 } 162 163 arp_protos_clear(&device->protos );159 arp_addr_destroy(&proto->addresses, free); 160 } 161 } 162 163 arp_protos_clear(&device->protos, free); 164 164 } 165 165 … … 184 184 } 185 185 186 arp_cache_clear(&arp_globals.cache );186 arp_cache_clear(&arp_globals.cache, free); 187 187 fibril_mutex_unlock(&arp_globals.lock); 188 188 … … 212 212 arp_clear_trans(trans); 213 213 214 arp_addr_exclude(&proto->addresses, address->value, address->length );214 arp_addr_exclude(&proto->addresses, address->value, address->length, free); 215 215 216 216 fibril_mutex_unlock(&arp_globals.lock); … … 345 345 header->protocol_length, trans); 346 346 if (rc != EOK) { 347 /* The generic char map has already freed trans! */347 free(trans); 348 348 return rc; 349 349 } … … 556 556 if (index < 0) { 557 557 fibril_mutex_unlock(&arp_globals.lock); 558 arp_protos_destroy(&device->protos );558 arp_protos_destroy(&device->protos, free); 559 559 free(device); 560 560 return index; … … 569 569 if (device->phone < 0) { 570 570 fibril_mutex_unlock(&arp_globals.lock); 571 arp_protos_destroy(&device->protos );571 arp_protos_destroy(&device->protos, free); 572 572 free(device); 573 573 return EREFUSED; … … 579 579 if (rc != EOK) { 580 580 fibril_mutex_unlock(&arp_globals.lock); 581 arp_protos_destroy(&device->protos );581 arp_protos_destroy(&device->protos, free); 582 582 free(device); 583 583 return rc; … … 589 589 if (rc != EOK) { 590 590 fibril_mutex_unlock(&arp_globals.lock); 591 arp_protos_destroy(&device->protos );591 arp_protos_destroy(&device->protos, free); 592 592 free(device); 593 593 return rc; … … 601 601 free(device->addr); 602 602 free(device->addr_data); 603 arp_protos_destroy(&device->protos );603 arp_protos_destroy(&device->protos, free); 604 604 free(device); 605 605 return rc; … … 614 614 free(device->broadcast_addr); 615 615 free(device->broadcast_data); 616 arp_protos_destroy(&device->protos );616 arp_protos_destroy(&device->protos, free); 617 617 free(device); 618 618 return rc; … … 746 746 arp_clear_trans(trans); 747 747 arp_addr_exclude(&proto->addresses, target->value, 748 target->length );748 target->length, free); 749 749 return EAGAIN; 750 750 } … … 794 794 trans); 795 795 if (rc != EOK) { 796 /* The generic char map has already freed trans! */796 free(trans); 797 797 return rc; 798 798 } … … 807 807 arp_clear_trans(trans); 808 808 arp_addr_exclude(&proto->addresses, target->value, 809 target->length );809 target->length, free); 810 810 return ENOENT; 811 811 } -
uspace/srv/net/il/ip/ip.c
r2afc54d r93ebe4e 505 505 if (rc != EOK) { 506 506 fibril_rwlock_write_unlock(&ip_globals.netifs_lock); 507 ip_routes_destroy(&ip_netif->routes );507 ip_routes_destroy(&ip_netif->routes, free); 508 508 free(ip_netif); 509 509 return rc; -
uspace/srv/net/net/net.c
r2afc54d r93ebe4e 555 555 rc = read_netif_configuration(conf_files[i], netif); 556 556 if (rc != EOK) { 557 measured_strings_destroy(&netif->configuration );557 measured_strings_destroy(&netif->configuration, free); 558 558 free(netif); 559 559 return rc; … … 565 565 if (!setting) { 566 566 fprintf(stderr, "%s: Network interface name is missing\n", NAME); 567 measured_strings_destroy(&netif->configuration );567 measured_strings_destroy(&netif->configuration, free); 568 568 free(netif); 569 569 return EINVAL; … … 574 574 int index = netifs_add(&net_globals.netifs, netif->id, netif); 575 575 if (index < 0) { 576 measured_strings_destroy(&netif->configuration );576 measured_strings_destroy(&netif->configuration, free); 577 577 free(netif); 578 578 return index; … … 586 586 index); 587 587 if (rc != EOK) { 588 measured_strings_destroy(&netif->configuration );589 netifs_exclude_index(&net_globals.netifs, index );588 measured_strings_destroy(&netif->configuration, free); 589 netifs_exclude_index(&net_globals.netifs, index, free); 590 590 return rc; 591 591 } … … 595 595 printf("%s: Ignoring failed interface %s (%s)\n", NAME, 596 596 netif->name, str_error(rc)); 597 measured_strings_destroy(&netif->configuration );598 netifs_exclude_index(&net_globals.netifs, index );597 measured_strings_destroy(&netif->configuration, free); 598 netifs_exclude_index(&net_globals.netifs, index, free); 599 599 continue; 600 600 } -
uspace/srv/net/nil/eth/eth.c
r2afc54d r93ebe4e 214 214 if (rc != EOK) { 215 215 free(eth_globals.broadcast_addr); 216 eth_devices_destroy(ð_globals.devices );216 eth_devices_destroy(ð_globals.devices, free); 217 217 } 218 218 out: -
uspace/srv/net/tl/tcp/tcp.c
r2afc54d r93ebe4e 1707 1707 if (socket->port > 0) { 1708 1708 socket_ports_exclude(&tcp_globals.sockets, 1709 socket->port );1709 socket->port, free); 1710 1710 socket->port = 0; 1711 1711 } … … 2492 2492 rc = packet_dimensions_initialize(&tcp_globals.dimensions); 2493 2493 if (rc != EOK) { 2494 socket_ports_destroy(&tcp_globals.sockets );2494 socket_ports_destroy(&tcp_globals.sockets, free); 2495 2495 goto out; 2496 2496 } -
uspace/srv/net/tl/udp/udp.c
r2afc54d r93ebe4e 417 417 rc = packet_dimensions_initialize(&udp_globals.dimensions); 418 418 if (rc != EOK) { 419 socket_ports_destroy(&udp_globals.sockets );419 socket_ports_destroy(&udp_globals.sockets, free); 420 420 fibril_rwlock_write_unlock(&udp_globals.lock); 421 421 return rc; … … 434 434 &data); 435 435 if (rc != EOK) { 436 socket_ports_destroy(&udp_globals.sockets );436 socket_ports_destroy(&udp_globals.sockets, free); 437 437 fibril_rwlock_write_unlock(&udp_globals.lock); 438 438 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.