Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs24-19fa
git_rec_nano
Commits
8b28de13
Commit
8b28de13
authored
8 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: don't call a thing malloc... when it doesn't call malloc()
parent
8fa72fb7
master
feature/match-parens
refactor/readbility
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/browser.c
+3
-3
src/browser.c
src/files.c
+1
-1
src/files.c
src/proto.h
+1
-1
src/proto.h
src/utils.c
+2
-4
src/utils.c
with
7 additions
and
9 deletions
+7
-9
src/browser.c
View file @
8b28de13
...
...
@@ -65,7 +65,7 @@ char *do_browser(char *path)
read_directory_contents:
/* We come here when we refresh or select a new directory. */
path
=
mallocstr
assn
(
path
,
get_full_path
(
path
));
path
=
free_and_
ass
ig
n
(
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
=
mallocstr
assn
(
path
,
real_dir_from_tilde
(
answer
));
path
=
free_and_
ass
ig
n
(
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
=
mallocstr
assn
(
path
,
striponedir
(
path
));
path
=
free_and_
ass
ig
n
(
path
,
striponedir
(
path
));
if
(
stat
(
path
,
&
st
)
==
-
1
||
!
S_ISDIR
(
st
.
st_mode
))
{
char
*
currentdir
=
charalloc
(
PATH_MAX
+
1
);
...
...
This diff is collapsed.
Click to expand it.
src/files.c
View file @
8b28de13
...
...
@@ -1226,7 +1226,7 @@ void do_insertfile(
{
/* Make sure the path to the file specified in answer is
* tilde-expanded. */
answer
=
mallocstr
assn
(
answer
,
real_dir_from_tilde
(
answer
));
answer
=
free_and_
ass
ig
n
(
answer
,
real_dir_from_tilde
(
answer
));
/* Save the file specified in answer in the current buffer. */
open_buffer
(
answer
,
TRUE
);
...
...
This diff is collapsed.
Click to expand it.
src/proto.h
View file @
8b28de13
...
...
@@ -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
*
mallocstr
assn
(
char
*
dest
,
char
*
src
);
char
*
free_and_
ass
ig
n
(
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
);
...
...
This diff is collapsed.
Click to expand it.
src/utils.c
View file @
8b28de13
...
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help