Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
42cb422e
Commit
42cb422e
authored
Feb 07, 2016
by
yoav@monfort.co.il
Committed by
antirez
Feb 10, 2016
Browse files
cmsgpack: pass correct osize values to lua allocator, update correct buf free space in cmsgpack
parent
32535ff5
Changes
1
Hide whitespace changes
Inline
Side-by-side
deps/lua/src/lua_cmsgpack.c
View file @
42cb422e
...
...
@@ -119,10 +119,10 @@ mp_buf *mp_buf_new(lua_State *L) {
void
mp_buf_append
(
mp_buf
*
buf
,
const
unsigned
char
*
s
,
size_t
len
)
{
if
(
buf
->
free
<
len
)
{
size_t
new
len
=
buf
->
len
+
len
;
size_t
new
size
=
(
buf
->
len
+
len
)
*
2
;
buf
->
b
=
(
unsigned
char
*
)
mp_realloc
(
buf
->
L
,
buf
->
b
,
buf
->
len
,
newlen
*
2
);
buf
->
free
=
newlen
;
buf
->
b
=
(
unsigned
char
*
)
mp_realloc
(
buf
->
L
,
buf
->
b
,
buf
->
len
+
buf
->
free
,
newsize
);
buf
->
free
=
new
size
-
buf
->
len
;
}
memcpy
(
buf
->
b
+
buf
->
len
,
s
,
len
);
buf
->
len
+=
len
;
...
...
@@ -130,7 +130,7 @@ void mp_buf_append(mp_buf *buf, const unsigned char *s, size_t len) {
}
void
mp_buf_free
(
mp_buf
*
buf
)
{
mp_realloc
(
buf
->
L
,
buf
->
b
,
buf
->
len
,
0
);
/* realloc to 0 = free */
mp_realloc
(
buf
->
L
,
buf
->
b
,
buf
->
len
+
buf
->
free
,
0
);
/* realloc to 0 = free */
mp_realloc
(
buf
->
L
,
buf
,
sizeof
(
*
buf
),
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