~bl4ckb0ne/boson

d861832f5e415faf1e20efa2ed99f8c77cbd774c — Simon Zeni 3 months ago 10c8468
builtin: dont store abs path in files function
1 files changed, 0 insertions(+), 10 deletions(-)

M src/builtin.c
M src/builtin.c => src/builtin.c +0 -10
@@ 156,16 156,6 @@ files(struct context *ctx, struct ast_arguments *args)
		}
		struct object *file = eval_string(expr->data.string);

		char abs_path[PATH_MAX] = {0};
		snprintf(abs_path, PATH_MAX, "%s/%s", cwd, file->string.data);

		const size_t path_size = strlen(abs_path) + 1;
		file->string.data = realloc(file->string.data,
				path_size * sizeof(char));

		strncpy(file->string.data, abs_path, path_size);
		file->string.n = path_size;

		const size_t files_size = files->array.n + 1;
		files->array.objects = realloc(files->array.objects,
			files_size * sizeof(struct object));