Browse Source

smalloc: expose ExternalArraySize

Useful to correctly determine the byte size of the external memory that
needs to be allocated for an external array.
v0.11.6-release
Trevor Norris 12 years ago
parent
commit
ed0677f427
  1. 2
      src/smalloc.cc
  2. 5
      src/smalloc.h

2
src/smalloc.cc

@ -69,7 +69,7 @@ static bool using_alloc_cb;
// return size of external array type, or 0 if unrecognized
static inline size_t ExternalArraySize(enum ExternalArrayType type) {
size_t ExternalArraySize(enum ExternalArrayType type) {
switch (type) {
case v8::kExternalUnsignedByteArray:
return sizeof(uint8_t);

5
src/smalloc.h

@ -41,6 +41,11 @@ static const unsigned int kMaxLength = 0x3fffffff;
NODE_EXTERN typedef void (*FreeCallback)(char* data, void* hint);
/**
* Return byte size of external array type.
*/
NODE_EXTERN size_t ExternalArraySize(enum v8::ExternalArrayType type);
/**
* Allocate external memory and set to passed object. If data is passed then
* will use that instead of allocating new.

Loading…
Cancel
Save