mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
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.
This commit is contained in:
parent
a0792e743f
commit
d32829e053
1 changed files with 2 additions and 3 deletions
|
|
@ -1011,17 +1011,16 @@ pub const Manifest = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Like `addFilePost` but when the file contents have already been loaded from disk.
|
/// Like `addFilePost` but when the file contents have already been loaded from disk.
|
||||||
/// On success, cache takes ownership of `resolved_path`.
|
|
||||||
pub fn addFilePostContents(
|
pub fn addFilePostContents(
|
||||||
self: *Manifest,
|
self: *Manifest,
|
||||||
resolved_path: []u8,
|
file_path: []const u8,
|
||||||
bytes: []const u8,
|
bytes: []const u8,
|
||||||
stat: File.Stat,
|
stat: File.Stat,
|
||||||
) !void {
|
) !void {
|
||||||
assert(self.manifest_file != null);
|
assert(self.manifest_file != null);
|
||||||
const gpa = self.cache.gpa;
|
const gpa = self.cache.gpa;
|
||||||
|
|
||||||
const prefixed_path = try self.cache.findPrefixResolved(resolved_path);
|
const prefixed_path = try self.cache.findPrefix(file_path);
|
||||||
errdefer gpa.free(prefixed_path.sub_path);
|
errdefer gpa.free(prefixed_path.sub_path);
|
||||||
|
|
||||||
const gop = try self.files.getOrPutAdapted(gpa, prefixed_path, FilesAdapter{});
|
const gop = try self.files.getOrPutAdapted(gpa, prefixed_path, FilesAdapter{});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue