mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-03-01 16:14:38 +01:00
Use glib malloc instead of malloc
This commit is contained in:
parent
c0306b8706
commit
1be84c6c3b
1 changed files with 3 additions and 3 deletions
|
@ -556,13 +556,13 @@ get_window_title_filename(zathura_t* zathura, const char* file_path)
|
|||
girara_setting_get(zathura->ui.session, "window-title-home-tilde", &home_tilde);
|
||||
if (home_tilde) {
|
||||
char *home = getenv("HOME");
|
||||
int home_len = home ? strlen(home) : 0;
|
||||
int file_path_len = file_path ? strlen(file_path) : 0;
|
||||
size_t home_len = home ? strlen(home) : 0;
|
||||
size_t file_path_len = file_path ? strlen(file_path) : 0;
|
||||
|
||||
if (home_len > 1 && strncmp(home, file_path, home_len) == 0 && (!file_path[home_len] || file_path[home_len] == '/')) {
|
||||
// Length should be total length of path - length of $HOME + 1 for '~' + 1 for '\0'
|
||||
int tlen = file_path_len - home_len + 2;
|
||||
char *tdir = malloc(sizeof(char) * tlen);
|
||||
char *tdir = g_try_malloc(sizeof(char) * tlen);
|
||||
strncpy(tdir + 1, file_path + home_len, tlen);
|
||||
tdir[0] = '~';
|
||||
tdir[tlen - 1] = '\0';
|
||||
|
|
Loading…
Add table
Reference in a new issue