projects
/
jansson.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
jansson 2.0
[jansson.git]
/
src
/
strbuffer.c
diff --git
a/src/strbuffer.c
b/src/strbuffer.c
index
4e866bd
..
758e95e
100644
(file)
--- a/
src/strbuffer.c
+++ b/
src/strbuffer.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 2009
, 2010
Petri Lehtinen <petri@digip.org>
+ * Copyright (c) 2009
-2011
Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
@@
-68,12
+68,21
@@
int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, int size)
{
if(strbuff->length + size >= strbuff->size)
{
{
if(strbuff->length + size >= strbuff->size)
{
- s
trbuff->size = max(strbuff->size * STRBUFFER_FACTOR,
-
strbuff->length + size + 1)
;
+ s
ize_t new_size;
+
char *new_value
;
- strbuff->value = realloc(strbuff->value, strbuff->size);
- if(!strbuff->value)
+ new_size = max(strbuff->size * STRBUFFER_FACTOR,
+ strbuff->length + size + 1);
+
+ new_value = jsonp_malloc(new_size);
+ if(!new_value)
return -1;
return -1;
+
+ memcpy(new_value, strbuff->value, strbuff->length);
+
+ jsonp_free(strbuff->value);
+ strbuff->value = new_value;
+ strbuff->size = new_size;
}
memcpy(strbuff->value + strbuff->length, data, size);
}
memcpy(strbuff->value + strbuff->length, data, size);