tweaks: don't call a thing malloc... when it doesn't call malloc()
parent
8fa72fb7e7
commit
8b28de1313
|
@ -65,7 +65,7 @@ char *do_browser(char *path)
|
|||
read_directory_contents:
|
||||
/* We come here when we refresh or select a new directory. */
|
||||
|
||||
path = mallocstrassn(path, get_full_path(path));
|
||||
path = free_and_assign(path, get_full_path(path));
|
||||
|
||||
if (path != NULL)
|
||||
dir = opendir(path);
|
||||
|
@ -243,7 +243,7 @@ char *do_browser(char *path)
|
|||
sunder(answer);
|
||||
align(&answer);
|
||||
|
||||
path = mallocstrassn(path, real_dir_from_tilde(answer));
|
||||
path = free_and_assign(path, real_dir_from_tilde(answer));
|
||||
|
||||
/* If the given path is relative, join it with the current path. */
|
||||
if (*path != '/') {
|
||||
|
@ -367,7 +367,7 @@ char *do_browse_from(const char *inpath)
|
|||
* at all. If so, we'll just pass the current directory to
|
||||
* do_browser(). */
|
||||
if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
|
||||
path = mallocstrassn(path, striponedir(path));
|
||||
path = free_and_assign(path, striponedir(path));
|
||||
|
||||
if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
|
||||
char * currentdir = charalloc(PATH_MAX + 1);
|
||||
|
|
|
@ -1226,7 +1226,7 @@ void do_insertfile(
|
|||
{
|
||||
/* Make sure the path to the file specified in answer is
|
||||
* tilde-expanded. */
|
||||
answer = mallocstrassn(answer, real_dir_from_tilde(answer));
|
||||
answer = free_and_assign(answer, real_dir_from_tilde(answer));
|
||||
|
||||
/* Save the file specified in answer in the current buffer. */
|
||||
open_buffer(answer, TRUE);
|
||||
|
|
|
@ -728,7 +728,7 @@ void *nmalloc(size_t howmuch);
|
|||
void *nrealloc(void *ptr, size_t howmuch);
|
||||
char *mallocstrncpy(char *dest, const char *src, size_t n);
|
||||
char *mallocstrcpy(char *dest, const char *src);
|
||||
char *mallocstrassn(char *dest, char *src);
|
||||
char *free_and_assign(char *dest, char *src);
|
||||
size_t get_page_start(size_t column);
|
||||
size_t xplustabs(void);
|
||||
size_t actual_x(const char *s, size_t column);
|
||||
|
|
|
@ -427,10 +427,8 @@ char *mallocstrcpy(char *dest, const char *src)
|
|||
return mallocstrncpy(dest, src, (src == NULL) ? 1 : strlen(src) + 1);
|
||||
}
|
||||
|
||||
/* Free the malloc()ed string at dest and return the malloc()ed string
|
||||
* at src. Should be used as: "answer = mallocstrassn(answer,
|
||||
* real_dir_from_tilde(answer));". */
|
||||
char *mallocstrassn(char *dest, char *src)
|
||||
/* Free the string at dest and return the string at src. */
|
||||
char *free_and_assign(char *dest, char *src)
|
||||
{
|
||||
free(dest);
|
||||
return src;
|
||||
|
|
Loading…
Reference in New Issue