Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
5921f91a
Commit
5921f91a
authored
Dec 28, 2015
by
Federico G. Schwindt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use realloc if possible
Avoids memcpy/free if the buffer was dynamic.
parent
446695e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
vsb.c
lib/libvarnish/vsb.c
+7
-5
No files found.
lib/libvarnish/vsb.c
View file @
5921f91a
...
...
@@ -142,14 +142,16 @@ VSB_extend(struct vsb *s, int addlen)
if
(
!
VSB_CANEXTEND
(
s
))
return
(
-
1
);
newsize
=
VSB_extendsize
(
s
->
s_size
+
addlen
);
newbuf
=
SBMALLOC
(
newsize
);
if
(
newbuf
==
NULL
)
return
(
-
1
);
memcpy
(
newbuf
,
s
->
s_buf
,
s
->
s_size
);
if
(
VSB_ISDYNAMIC
(
s
))
SBFREE
(
s
->
s_buf
);
newbuf
=
realloc
(
s
->
s_buf
,
newsize
);
else
newbuf
=
SBMALLOC
(
newsize
);
if
(
newbuf
==
NULL
)
return
(
-
1
);
if
(
!
VSB_ISDYNAMIC
(
s
))
{
memcpy
(
newbuf
,
s
->
s_buf
,
s
->
s_size
);
VSB_SETFLAG
(
s
,
VSB_DYNAMIC
);
}
s
->
s_buf
=
newbuf
;
s
->
s_size
=
newsize
;
return
(
0
);
...
...
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