0

I'm using a Solidity mapping of mapping to manage associations between files and users in my application and deleting elements from it like this:


mapping(address => mapping(address => uint)) public userfiles;

function deleteFile(address useraddr, address fileaddr) public fileExists(fileaddr) {
    delete userfiles[useraddr][fileaddr];
    // other code
}

I'm visualizing the mapping like this:

address(useraddr) --> (address(fileaddr) --> uint)

I can have multiple of the inner mappings (files) mapped to one outer mapping (users). With my code I have gotten no compilation error so far.

My question is what happens if a useraddr is pointing to (or mapped to) only one fileaddr and I delete the inner fileaddr mapping as in my code? Will it give rise to a situation similar to a dangling pointer or a memory leak? Also, is there a way to delete the particular outer useraddr mapping as well for this special case?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.