core/bus_center/lnn/net_ledger/common/src/lnn_map.c
/**
 * Erase map node
 *
 * @param : map Map see details in type Map
 *          key Map key
 */
Erase map node
@param : map Map see details in type Map
key Map key
Erase map node @param : map Map see details in type Map key Map key
int32_t LnnMapErase(Map *map, const char *key)
{
    if (map == NULL || key == NULL || map->nodeSize == 0 || map->nodes == NULL) {
        return SOFTBUS_INVALID_PARAM;
    }
    uint32_t hash = MapHash(key);
    uint32_t idx = MapHashIdx(map, hash);
    MapNode *node = map->nodes[idx];
    MapNode *prev = node;
    while (node != NULL) {
        if (node->hash == hash && node->key != NULL && !strcmp(node->key, key)) {
            if (map->nodes[idx] == node) {
                map->nodes[idx] = node->next;
            } else {
                prev->next = node->next;
            }
            SoftBusFree(node);
            map->nodeSize--;
            return SOFTBUS_OK;
        }
        prev = node;
        node = node->next;
    }
    return SOFTBUS_ERR;
}
int32_t LnnMapErase ( Map * map , const char * key ) { if ( map == NULL || key == NULL || map -> nodeSize == 0 || map -> nodes == NULL ) { return SOFTBUS_INVALID_PARAM ; } uint32_t hash = MapHash ( key ) ; uint32_t idx = MapHashIdx ( map , hash ) ; MapNode * node = map -> nodes [ idx ] ; MapNode * prev = node ; while ( node != NULL ) { if ( node -> hash == hash && node -> key != NULL && ! strcmp ( node -> key , key ) ) { if ( map -> nodes [ idx ] == node ) { map -> nodes [ idx ] = node -> next ; } else { prev -> next = node -> next ; } SoftBusFree ( node ) ; map -> nodeSize -- ; return SOFTBUS_OK ; } prev = node ; node = node -> next ; } return SOFTBUS_ERR ; }
Erase map node
 @param : map Map see details in type Map
          key Map key
Erase map node @param : map Map see details in type Map key Map key