Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shell: Allocate proper amount of history slab memory #13048

Merged
merged 1 commit into from
Feb 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/shell/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ extern void shell_print_stream(const void *user_ctx, const char *data,
SHELL_LOG_BACKEND_DEFINE(_name, _name##_out_buffer, \
CONFIG_SHELL_PRINTF_BUFF_SIZE, \
_log_queue_size, _log_timeout); \
SHELL_HISTORY_DEFINE(_name, 128, 8);/*todo*/ \
SHELL_HISTORY_DEFINE(_name, CONFIG_SHELL_CMD_BUFF_SIZE, 7); \
SHELL_FPRINTF_DEFINE(_name##_fprintf, &_name, _name##_out_buffer, \
CONFIG_SHELL_PRINTF_BUFF_SIZE, \
true, shell_print_stream); \
Expand Down
10 changes: 9 additions & 1 deletion include/shell/shell_history.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,19 @@ struct shell_history {
sys_dlist_t list;
sys_dnode_t *current;
};

struct shell_history_item {
sys_dnode_t dnode;
u16_t len;
char data[];
};

#if CONFIG_SHELL_HISTORY
#define SHELL_HISTORY_DEFINE(_name, block_size, block_count) \
\
K_MEM_SLAB_DEFINE(_name##_history_memslab, \
block_size, block_count, 4); \
ROUND_UP(block_size + sizeof(struct shell_history_item), \
sizeof(void *)), block_count, 4); \
static struct shell_history _name##_history = { \
.mem_slab = &_name##_history_memslab \
}
Expand Down
6 changes: 0 additions & 6 deletions subsys/shell/shell_history.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
#include <shell/shell_history.h>
#include <string.h>

struct shell_history_item {
sys_dnode_t dnode;
u16_t len;
char data[1];
};

void shell_history_mode_exit(struct shell_history *history)
{
history->current = NULL;
Expand Down