Skip to content

Commit d32829e

Browse files
committed
std.Build.Cache: change contract of addFilePostContents
This function was broken, because it took ownership of the buffer on error *sometimes*, in a way which the caller could not tell. Rather than trying to be clever, it's easier to just follow the same interface as all other `addFilePost` methods, and not take ownership of the path. This is a breaking change. The next commits will apply it to the compiler, which is the only user of this function in the ziglang/zig repository.
1 parent a0792e7 commit d32829e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/std/Build/Cache.zig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,17 +1011,16 @@ pub const Manifest = struct {
10111011
}
10121012

10131013
/// Like `addFilePost` but when the file contents have already been loaded from disk.
1014-
/// On success, cache takes ownership of `resolved_path`.
10151014
pub fn addFilePostContents(
10161015
self: *Manifest,
1017-
resolved_path: []u8,
1016+
file_path: []const u8,
10181017
bytes: []const u8,
10191018
stat: File.Stat,
10201019
) !void {
10211020
assert(self.manifest_file != null);
10221021
const gpa = self.cache.gpa;
10231022

1024-
const prefixed_path = try self.cache.findPrefixResolved(resolved_path);
1023+
const prefixed_path = try self.cache.findPrefix(file_path);
10251024
errdefer gpa.free(prefixed_path.sub_path);
10261025

10271026
const gop = try self.files.getOrPutAdapted(gpa, prefixed_path, FilesAdapter{});

0 commit comments

Comments
 (0)