DoxigAlpha

putMove

Same as put but the key and value become owned by the BufMap rather than being copied. If putMove fails, the ownership of key and value does not transfer.

Function parameters

Parameters

#
self:*BufMap
key:[]u8
value:[]u8

BufMap copies keys and values before they go into the map and

Types

#
BufMap
BufMap copies keys and values before they go into the map and

Source

Implementation

#
pub fn putMove(self: *BufMap, key: []u8, value: []u8) !void {
    const get_or_put = try self.hash_map.getOrPut(key);
    if (get_or_put.found_existing) {
        self.free(get_or_put.key_ptr.*);
        self.free(get_or_put.value_ptr.*);
        get_or_put.key_ptr.* = key;
    }
    get_or_put.value_ptr.* = value;
}