Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Avoid allocating too little memory and too often

  • Loading branch information...
commit 3e9a54b7908171aa9fba919220743ede1803dade 1 parent af8de87
Filipe Manana authored

Showing 1 changed file with 1 addition and 3 deletions. Show diff stats Hide diff stats

  1. +1 3 c_src/snappy.cc
4 c_src/snappy.cc
@@ -27,8 +27,6 @@
27 27 #endif
28 28
29 29
30   -const size_t ALLOC_SIZE = 2048;
31   -
32 30 class OutOfMem {};
33 31
34 32
@@ -50,7 +48,7 @@ class SnappyNifSink : public snappy::Sink {
50 48
51 49 char* GetAppendBuffer(size_t len, char* scratch) {
52 50 if ((length + len) > bin.size) {
53   - size_t sz = len > ALLOC_SIZE ? len + ALLOC_SIZE - (len % ALLOC_SIZE) : ALLOC_SIZE;
  51 + size_t sz = (len * 4) < 8192 ? 8192 : (len * 4);
54 52
55 53 if (!enif_realloc_binary_compat(env, &bin, bin.size + sz)) {
56 54 enif_release_binary_compat(env, &bin);

0 comments on commit 3e9a54b

Please sign in to comment.
Something went wrong with that request. Please try again.