Skip to content

Commit

Permalink
Rename deinit functions to testDeinit and comment out any deinit call…
Browse files Browse the repository at this point in the history
…s from other modules
  • Loading branch information
malcolmstill committed Mar 31, 2024
1 parent c2d833e commit 83b2d5f
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions biscuit-datalog/src/check.zig
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ pub const Check = struct {
return .{ .queries = rules, .kind = kind };
}

pub fn deinit(check: *Check) void {
pub fn testDeinit(check: *Check) void {
for (check.queries.items) |*query| {
query.deinit();
query.testDeinit();
}

check.queries.deinit();
Expand Down
8 changes: 4 additions & 4 deletions biscuit-datalog/src/fact_set.zig
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ pub const FactSet = struct {
// value as a key, and we try to insert into hashmap that already contains that value,
// we will leak the key if we don't detect the existing version and deallocate one of the
// keys.
pub fn deinit(fact_set: *FactSet) void {
pub fn testDeinit(fact_set: *FactSet) void {
var it = fact_set.sets.iterator();

while (it.next()) |origin_facts| {
origin_facts.key_ptr.deinit(); // Okay, in practice this is also giving us incorrect alignment issues
origin_facts.key_ptr.testDeinit(); // Okay, in practice this is also giving us incorrect alignment issues
origin_facts.value_ptr.deinit();
}

Expand Down Expand Up @@ -150,7 +150,7 @@ test "FactSet trustedIterator" {
const Term = @import("term.zig").Term;

var fs = FactSet.init(testing.allocator);
defer fs.deinit();
defer fs.testDeinit();

var origin = Origin.init(testing.allocator);
try origin.insert(0);
Expand Down Expand Up @@ -184,7 +184,7 @@ test "FactSet trustedIterator" {
// With a trusted iterator only trusting [0] we only expect a single fact
{
var trusted_origins = try TrustedOrigins.defaultOrigins(testing.allocator);
defer trusted_origins.deinit();
defer trusted_origins.testDeinit();

var count: usize = 0;

Expand Down
6 changes: 2 additions & 4 deletions biscuit-datalog/src/origin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ pub const Origin = struct {
return .{ .block_ids = block_ids };
}

pub fn deinit(origin: *Origin) void {
if (@import("builtin").mode != .Debug) unreachable; // .deinit only used in tests

pub fn testDeinit(origin: *Origin) void {
origin.block_ids.deinit();
}

Expand Down Expand Up @@ -96,7 +94,7 @@ test "Origins" {
const testing = std.testing;

var origins = Origin.init(testing.allocator);
defer origins.deinit();
defer origins.testDeinit();

try origins.insert(12);
try origins.insert(13);
Expand Down
6 changes: 3 additions & 3 deletions biscuit-datalog/src/rule_set.zig
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ pub const RuleSet = struct {
};
}

pub fn deinit(rule_set: *RuleSet) void {
pub fn testDeinit(rule_set: *RuleSet) void {
var it = rule_set.rules.iterator();

while (it.next()) |entry| {
entry.key_ptr.deinit();
entry.key_ptr.testDeinit();
entry.value_ptr.deinit();
}

Expand All @@ -44,7 +44,7 @@ test "RuleSet" {
const test_log = std.log.scoped(.test_rule_set);

var rs = RuleSet.init(testing.allocator);
defer rs.deinit();
defer rs.testDeinit();

const default_origins = try TrustedOrigins.defaultOrigins(testing.allocator);
const rule: Rule = undefined;
Expand Down
6 changes: 3 additions & 3 deletions biscuit-datalog/src/trusted_origins.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub const TrustedOrigins = struct {
return .{ .ids = InnerSet.init(allocator) };
}

pub fn deinit(trusted_origins: *TrustedOrigins) void {
pub fn testDeinit(trusted_origins: *TrustedOrigins) void {
trusted_origins.ids.deinit();
}

Expand Down Expand Up @@ -124,10 +124,10 @@ test "Trusted origin" {
const testing = std.testing;

var to = try TrustedOrigins.defaultOrigins(testing.allocator);
defer to.deinit();
defer to.testDeinit();

var o = Origin.init(testing.allocator);
defer o.deinit();
defer o.testDeinit();

try o.insert(22);

Expand Down
2 changes: 1 addition & 1 deletion biscuit-datalog/src/world.zig
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub const World = struct {
const starting_fact_count = world.fact_set.count();

var new_fact_sets = FactSet.init(world.arena);
defer new_fact_sets.deinit();
// defer new_fact_sets.deinit();

// Iterate over rules to generate new facts
{
Expand Down
6 changes: 3 additions & 3 deletions biscuit/src/block.zig
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ pub const Block = struct {
}

pub fn deinit(block: *Block) void {
for (block.checks.items) |*check| check.deinit();
for (block.rules.items) |*rule| rule.deinit();
for (block.facts.items) |*fact| fact.deinit();
// for (block.checks.items) |*check| check.deinit();
// for (block.rules.items) |*rule| rule.deinit();
// for (block.facts.items) |*fact| fact.deinit();

block.checks.deinit();
block.rules.deinit();
Expand Down

0 comments on commit 83b2d5f

Please sign in to comment.