Changeset 9bddf37 in mainline


Ignore:
Timestamp:
2010-01-26T19:03:36Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e056e820
Parents:
88e870e
Message:

Free up node's resources in the 'nodes' hash table remove callback.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/tmpfs/tmpfs_ops.c

    r88e870e r9bddf37  
    166166static void nodes_remove_callback(link_t *item)
    167167{
     168        tmpfs_node_t *nodep = hash_table_get_instance(item, tmpfs_node_t,
     169            nh_link);
     170
     171        while (!list_empty(&nodep->cs_head)) {
     172                tmpfs_dentry_t *dentryp = list_get_instance(nodep->cs_head.next,
     173                    tmpfs_dentry_t, link);
     174
     175                assert(nodep->type == TMPFS_DIRECTORY);
     176                list_remove(&dentryp->link);
     177                free(dentryp);
     178        }
     179
     180        if (nodep->data) {
     181                assert(nodep->type == TMPFS_FILE);
     182                free(nodep->data);
     183        }
     184        free(nodep->bp);
     185        free(nodep);
    168186}
    169187
     
    317335        hash_table_remove(&nodes, key, 2);
    318336
    319         if ((nodep->type == TMPFS_FILE) && (nodep->data))
    320                 free(nodep->data);
    321         free(nodep->bp);
    322         free(nodep);
     337        /*
     338         * The nodes_remove_callback() function takes care of the actual
     339         * resource deallocation.
     340         */
    323341        return EOK;
    324342}
Note: See TracChangeset for help on using the changeset viewer.