Skip to content

Commit

Permalink
fs: add buffer cleanup and reformat parameters
Browse files Browse the repository at this point in the history
Add a `cleanup` method to clear the buffer in the `Read` shard to ensure proper memory management. Reformat parameter declaration in the `Absolute` shard for consistency and clarity.
  • Loading branch information
sinkingsugar committed Nov 19, 2024
1 parent 17f359b commit 8594387
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion shards/modules/fs/fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ struct Read {

SHTypeInfo compose(const SHInstanceData &data) { return _binary ? CoreInfo::BytesType : CoreInfo::StringType; }

void cleanup(SHContext *context) {
_buffer = {};
}

SHVar activate(SHContext *context, const SHVar &input) {
_buffer.clear();
fs::path p(SHSTRING_PREFER_SHSTRVIEW(input));
Expand Down Expand Up @@ -625,7 +629,8 @@ struct Absolute {
static SHTypesInfo inputTypes() { return CoreInfo::StringType; }
static SHTypesInfo outputTypes() { return CoreInfo::StringType; }

PARAM_PARAMVAR(_canonical, "Canonical", "Whether to canonicalize the path, the file should exist for this to work", {CoreInfo::BoolType, CoreInfo::BoolVarType});
PARAM_PARAMVAR(_canonical, "Canonical", "Whether to canonicalize the path, the file should exist for this to work",
{CoreInfo::BoolType, CoreInfo::BoolVarType});
PARAM_IMPL(PARAM_IMPL_FOR(_canonical));

Absolute() { _canonical = Var(false); }
Expand Down

0 comments on commit 8594387

Please sign in to comment.