Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
7.5.6 : memory complexity optimisations
Browse files Browse the repository at this point in the history
Signed-off-by: Ari Archer <[email protected]>
  • Loading branch information
Ari Archer committed May 2, 2023
1 parent 93f01c2 commit 4f02795
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion baz
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[ "$BAZ_DEBUG" ] && set -x

export BAZ_VERSION='7.5.5'
export BAZ_VERSION='7.5.6'
export BAZ_DIR="$HOME/.local/share/baz"
export BAZ_CONFDIR="$HOME/.config/baz"
export BAZ_CONF="$BAZ_CONFDIR/config.env"
Expand Down
2 changes: 1 addition & 1 deletion loader/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static void alloc_file(const char *path, File *f) {

if (content_size > f->content_size) {
free(f->content);
f->content = malloc(content_size + 2);
f->content = malloc(content_size + 1);
}

f->content_size = content_size;
Expand Down
2 changes: 1 addition & 1 deletion loader/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ static void load_keybinds(char *path, const size_t base) {
closedir(dp);
}

int main(int argc, char **argv) {
int main(int argc, const char **argv) {
static size_t path_base;
static unsigned char stage_num;
static stage_t stage;
Expand Down
11 changes: 9 additions & 2 deletions loader/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ static void escape_quotes(File *);

#ifdef SHELL_IMPL
static void escape_quotes(File *file) {
size_t quotes = 0;
char *new_content, *old_ptr, *new_ptr;

new_content = malloc((file->content_size *= 2));
old_ptr = file->content, new_ptr = new_content;
old_ptr = file->content;
new_content = file->content;

while (*new_content)
quotes += (*new_content++ == '"');

new_content = malloc((file->content_size += quotes));
new_ptr = new_content;

while (*old_ptr) {
if (*old_ptr == '"')
Expand Down

0 comments on commit 4f02795

Please sign in to comment.