Skip to content

Commit

Permalink
req changes
Browse files Browse the repository at this point in the history
  • Loading branch information
HN026 committed Feb 4, 2024
1 parent f48cd5a commit 3179b9b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
40 changes: 20 additions & 20 deletions librz/core/tui/panels.c
Original file line number Diff line number Diff line change
Expand Up @@ -2846,12 +2846,12 @@ void __replace_cmd(RzCore *core, const char *title, const char *cmd) {
RzPanel *cur = __get_cur_panel(panels);
__free_panel_model(cur);
cur->model = RZ_NEW0(RzPanelModel);
char *tmp1 = rz_str_dup(title);
char *tmp = rz_str_dup(title);
free(cur->model->title);
cur->model->title = tmp1;
char *tmp2 = rz_str_dup(cmd);
cur->model->title = tmp;
tmp = rz_str_dup(cmd);
free(cur->model->cmd);
cur->model->cmd = tmp2;
cur->model->cmd = tmp;
__set_cmd_str_cache(core, cur, NULL);
__set_panel_addr(core, cur, core->offset);
cur->model->type = PANEL_TYPE_DEFAULT;
Expand Down Expand Up @@ -3026,19 +3026,19 @@ void __init_panel_param(RzCore *core, RzPanel *p, const char *title, const char
m->cmd = tmp;
}
} else if (cmd) {
char *tmp1 = rz_str_dup(cmd);
char *tmp = rz_str_dup(cmd);
free(m->title);
m->title = tmp1;
char *tmp2 = rz_str_dup(cmd);
m->title = tmp;
tmp = rz_str_dup(cmd);
free(m->cmd);
m->cmd = tmp2;
m->cmd = tmp;
} else {
char *tmp1 = rz_str_dup("");
char *tmp = rz_str_dup("");
free(m->title);
m->title = tmp1;
char *tmp2 = rz_str_dup("");
m->title = tmp;
tmp = rz_str_dup("");
free(m->cmd);
m->cmd = tmp2;
m->cmd = tmp;
}
__set_pcb(p);
if (RZ_STR_ISNOTEMPTY(m->cmd)) {
Expand Down Expand Up @@ -3558,12 +3558,12 @@ void __update_help(RzCore *core, RzPanels *ps) {
msg = help_msg_panels;
break;
}
char *tmp1 = rz_str_dup(cmd);
char *tmp = rz_str_dup(cmd);
free(p->model->title);
p->model->title = tmp1;
char *tmp2 = rz_str_dup(cmd);
p->model->title = tmp;
tmp = rz_str_dup(cmd);
free(p->model->cmd);
p->model->cmd = tmp2;
p->model->cmd = tmp;
rz_core_visual_append_help(rsb, title, msg);
if (!rsb) {
return;
Expand Down Expand Up @@ -5535,12 +5535,12 @@ RZ_IPI bool rz_load_panels_layout(RzCore *core, const char *_name) {
__set_geometry(&p->view->pos, x, y, w, h);
__init_panel_param(core, p, title, cmd);
if (rz_str_endswith(cmd, "Help")) {
char *tmp1 = rz_str_dup("Help");
char *tmp = rz_str_dup("Help");
free(p->model->title);
p->model->title = tmp1;
char *tmp2 = rz_str_dup("Help");
p->model->title = tmp;
tmp = rz_str_dup("Help");
free(p->model->cmd);
p->model->cmd = tmp2;
p->model->cmd = tmp;
RzStrBuf *rsb = rz_strbuf_new(NULL);
rz_core_visual_append_help(rsb, "Visual Ascii Art Panels", help_msg_panels);
if (!rsb) {
Expand Down
2 changes: 1 addition & 1 deletion librz/include/rz_util/rz_str.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ static inline const char *rz_str_get_null(const char *str) {
return str ? str : "(null)";
}
RZ_API char *rz_str_ndup(RZ_NULLABLE const char *ptr, int len);
RZ_API char *rz_str_dup(RZ_NULLABLE const char *str);
RZ_API RZ_OWN char *rz_str_dup(RZ_NULLABLE const char *str);
RZ_API int rz_str_delta(char *p, char a, char b);
RZ_API void rz_str_filter(char *str);
RZ_API const char *rz_str_tok(const char *str1, const char b, size_t len);
Expand Down
8 changes: 4 additions & 4 deletions librz/util/str.c
Original file line number Diff line number Diff line change
Expand Up @@ -1041,15 +1041,15 @@ RZ_API char *rz_str_ndup(RZ_NULLABLE const char *ptr, int len) {
}

/**
* @brief Duplicates a string.
* \brief Duplicates a string.
*
* This function duplicates the given string. If the input string is NULL,
* the function will return NULL.
*
* @param str The string to duplicate. Can be NULL.
* @return A new string which is a duplicate of the input string, or NULL if the input string was NULL.
* \param str The string to duplicate. Can be NULL.
* \return A new string which is a duplicate of the input string, or NULL if the input string was NULL.
*/
RZ_API char *rz_str_dup(RZ_NULLABLE const char *str) {
RZ_API RZ_OWN char *rz_str_dup(RZ_NULLABLE const char *str) {
return str ? strdup(str) : NULL;
}

Expand Down

0 comments on commit 3179b9b

Please sign in to comment.