| ... | ... | @@ -39,6 +39,7 @@ pub const BufMap = struct { |
| 39 | 39 | const get_or_put = try self.hash_map.getOrPut(key); |
| 40 | 40 | if (get_or_put.found_existing) { |
| 41 | 41 | self.free(get_or_put.entry.key); |
| 42 | self.free(get_or_put.entry.value); |
| 42 | 43 | get_or_put.entry.key = key; |
| 43 | 44 | } |
| 44 | 45 | get_or_put.entry.value = value; |
| ... | ... | @@ -88,7 +89,8 @@ pub const BufMap = struct { |
| 88 | 89 | }; |
| 89 | 90 | |
| 90 | 91 | test "BufMap" { |
| 91 | | var bufmap = BufMap.init(std.testing.allocator); |
| 92 | const allocator = std.testing.allocator; |
| 93 | var bufmap = BufMap.init(allocator); |
| 92 | 94 | defer bufmap.deinit(); |
| 93 | 95 | |
| 94 | 96 | try bufmap.set("x", "1"); |
| ... | ... | @@ -105,4 +107,7 @@ test "BufMap" { |
| 105 | 107 | |
| 106 | 108 | bufmap.delete("x"); |
| 107 | 109 | testing.expect(0 == bufmap.count()); |
| 110 | |
| 111 | try bufmap.setMove(try allocator.dupe(u8, "k"), try allocator.dupe(u8, "v1")); |
| 112 | try bufmap.setMove(try allocator.dupe(u8, "k"), try allocator.dupe(u8, "v2")); |
| 108 | 113 | } |