Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Avoid allocating too little memory and too often

  • Loading branch information...
commit 3e9a54b7908171aa9fba919220743ede1803dade 1 parent af8de87
@fdmanana authored
Showing with 1 addition and 3 deletions.
  1. +1 −3 c_src/snappy.cc
View
4 c_src/snappy.cc
@@ -27,8 +27,6 @@
#endif
-const size_t ALLOC_SIZE = 2048;
-
class OutOfMem {};
@@ -50,7 +48,7 @@ class SnappyNifSink : public snappy::Sink {
char* GetAppendBuffer(size_t len, char* scratch) {
if ((length + len) > bin.size) {
- size_t sz = len > ALLOC_SIZE ? len + ALLOC_SIZE - (len % ALLOC_SIZE) : ALLOC_SIZE;
+ size_t sz = (len * 4) < 8192 ? 8192 : (len * 4);
if (!enif_realloc_binary_compat(env, &bin, bin.size + sz)) {
enif_release_binary_compat(env, &bin);
Please sign in to comment.
Something went wrong with that request. Please try again.