Permalink
Browse files

Support usage when size = 0

I got an error when encoding an empty message (`{}`).
When the message is empty,  the size is 0 and `slab` is null, so`slice.call(slab, offset, offset += size);` gave me
```
Uncaught TypeError: Method get TypedArray.prototype.subarray called on incompatible receiver null
```
Adding this solved the issue for me. Please correct me if I was using it all wrong. 😂
  • Loading branch information...
fnlctrl committed Dec 18, 2016
1 parent bfac0ea commit e226f001e4e4633d64c52be4abc1915d7b7bd515
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/util/pool/index.js
@@ -34,7 +34,7 @@ function pool(alloc, slice, size) {
var slab = null;
var offset = SIZE;
return function pool_alloc(size) {
if (size > MAX)
if (size > MAX || size === 0)
return alloc(size);
if (offset + size > SIZE) {
slab = alloc(SIZE);

0 comments on commit e226f00

Please sign in to comment.