projects
/
tedtools.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
d87148e
)
fix reallocation memory in appendStringBuffer
author
teodor
<teodor>
Thu, 18 Feb 2010 13:10:41 +0000
(13:10 +0000)
committer
teodor
<teodor>
Thu, 18 Feb 2010 13:10:41 +0000
(13:10 +0000)
tmalloc.c
patch
|
blob
|
history
diff --git
a/tmalloc.c
b/tmalloc.c
index
0d51e75
..
8b16322
100644
(file)
--- a/
tmalloc.c
+++ b/
tmalloc.c
@@
-320,8
+320,11
@@
appendStringBuffer( StringBuffer *state, char *string, int stringlen) {
return state;
while ( state->len - ( state->ptr - state->buf ) < stringlen + 1 ) {
return state;
while ( state->len - ( state->ptr - state->buf ) < stringlen + 1 ) {
+ int diff = state->ptr - state->buf;
+
state->len *= 2;
state->buf = (char*)mcrealloc( (void*)state->buf, state->len );
state->len *= 2;
state->buf = (char*)mcrealloc( (void*)state->buf, state->len );
+ state->ptr = state->buf + diff;
}
memcpy(state->ptr, string, stringlen);
}
memcpy(state->ptr, string, stringlen);