Browse Source

AdjustAmountOfExternalAllocatedMemory() for PixelArray

v1.x
Tj Holowaychuk 14 years ago
parent
commit
13b1c00647
  1. 13
      src/PixelArray.cc

13
src/PixelArray.cc

@ -128,16 +128,23 @@ PixelArray::PixelArray(int width, int height):
} }
/* /*
* Allocate / zero data buffer. * Allocate / zero data buffer. Hint mem adjustment.
*/ */
uint8_t * uint8_t *
PixelArray::alloc() { PixelArray::alloc() {
_data = (uint8_t *) malloc(length()); int len = length();
memset(_data, 0, length()); _data = (uint8_t *) malloc(len);
memset(_data, 0, len);
V8::AdjustAmountOfExternalAllocatedMemory(len);
return _data; return _data;
} }
/*
* Hint mem adjustment.
*/
PixelArray::~PixelArray() { PixelArray::~PixelArray() {
V8::AdjustAmountOfExternalAllocatedMemory(-length());
free(_data); free(_data);
} }

Loading…
Cancel
Save