summaryrefslogtreecommitdiff
path: root/src/node_buffer.cc
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2014-10-11 16:52:07 +0200
committerFedor Indutny <fedor@indutny.com>2014-10-12 02:09:46 +0400
commit5fdff3854a4253681fb10aa626c8971e50834c10 (patch)
treebaa8b219fff28467b641d4f4f36a5b090f6cc6b2 /src/node_buffer.cc
parent75a461d0997e0a040c2194c5309c148f179563e9 (diff)
downloadnode-new-5fdff3854a4253681fb10aa626c8971e50834c10.tar.gz
src: replace assert() with CHECK()
Mechanically replace assert() statements with UNREACHABLE(), CHECK(), or CHECK_{EQ,NE,LT,GT,LE,GE}() statements. The exceptions are src/node.h and src/node_object_wrap.h because they are public headers. PR-URL: https://github.com/node-forward/node/pull/16 Reviewed-By: Fedor Indutny <fedor@indutny.com>
Diffstat (limited to 'src/node_buffer.cc')
-rw-r--r--src/node_buffer.cc25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/node_buffer.cc b/src/node_buffer.cc
index ae33b03b38..90c0eb5750 100644
--- a/src/node_buffer.cc
+++ b/src/node_buffer.cc
@@ -30,7 +30,6 @@
#include "v8-profiler.h"
#include "v8.h"
-#include <assert.h>
#include <string.h>
#include <limits.h>
@@ -47,7 +46,7 @@
char* obj_data = static_cast<char*>( \
obj->GetIndexedPropertiesExternalArrayData()); \
if (obj_length > 0) \
- assert(obj_data != NULL);
+ CHECK_NE(obj_data, NULL);
#define SLICE_START_END(start_arg, end_arg, end_max) \
size_t start; \
@@ -91,7 +90,7 @@ bool HasInstance(Handle<Object> obj) {
char* Data(Handle<Value> val) {
- assert(val->IsObject());
+ CHECK(val->IsObject());
// Use a fully qualified name here to work around a bug in gcc 4.2.
// It mistakes an unadorned call to Data() for the v8::String::Data type.
return node::Buffer::Data(val.As<Object>());
@@ -99,19 +98,19 @@ char* Data(Handle<Value> val) {
char* Data(Handle<Object> obj) {
- assert(obj->HasIndexedPropertiesInExternalArrayData());
+ CHECK(obj->HasIndexedPropertiesInExternalArrayData());
return static_cast<char*>(obj->GetIndexedPropertiesExternalArrayData());
}
size_t Length(Handle<Value> val) {
- assert(val->IsObject());
+ CHECK(val->IsObject());
return Length(val.As<Object>());
}
size_t Length(Handle<Object> obj) {
- assert(obj->HasIndexedPropertiesInExternalArrayData());
+ CHECK(obj->HasIndexedPropertiesInExternalArrayData());
return obj->GetIndexedPropertiesExternalArrayDataLength();
}
@@ -141,7 +140,7 @@ Local<Object> New(Isolate* isolate, size_t length) {
Local<Object> New(Environment* env, size_t length) {
EscapableHandleScope scope(env->isolate());
- assert(length <= kMaxLength);
+ CHECK_LE(length, kMaxLength);
Local<Value> arg = Uint32::NewFromUnsigned(env->isolate(), length);
Local<Object> obj = env->buffer_constructor_function()->NewInstance(1, &arg);
@@ -177,7 +176,7 @@ Local<Object> New(Isolate* isolate, const char* data, size_t length) {
Local<Object> New(Environment* env, const char* data, size_t length) {
EscapableHandleScope scope(env->isolate());
- assert(length <= kMaxLength);
+ CHECK_LE(length, kMaxLength);
Local<Value> arg = Uint32::NewFromUnsigned(env->isolate(), length);
Local<Object> obj = env->buffer_constructor_function()->NewInstance(1, &arg);
@@ -220,7 +219,7 @@ Local<Object> New(Environment* env,
void* hint) {
EscapableHandleScope scope(env->isolate());
- assert(length <= kMaxLength);
+ CHECK_LE(length, kMaxLength);
Local<Value> arg = Uint32::NewFromUnsigned(env->isolate(), length);
Local<Object> obj = env->buffer_constructor_function()->NewInstance(1, &arg);
@@ -242,7 +241,7 @@ Local<Object> Use(Isolate* isolate, char* data, uint32_t length) {
Local<Object> Use(Environment* env, char* data, uint32_t length) {
EscapableHandleScope scope(env->isolate());
- assert(length <= kMaxLength);
+ CHECK_LE(length, kMaxLength);
Local<Value> arg = Uint32::NewFromUnsigned(env->isolate(), length);
Local<Object> obj = env->buffer_constructor_function()->NewInstance(1, &arg);
@@ -591,13 +590,13 @@ void Compare(const FunctionCallbackInfo<Value> &args) {
void SetupBufferJS(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
- assert(args[0]->IsFunction());
+ CHECK(args[0]->IsFunction());
Local<Function> bv = args[0].As<Function>();
env->set_buffer_constructor_function(bv);
Local<Value> proto_v = bv->Get(env->prototype_string());
- assert(proto_v->IsObject());
+ CHECK(proto_v->IsObject());
Local<Object> proto = proto_v.As<Object>();
@@ -622,7 +621,7 @@ void SetupBufferJS(const FunctionCallbackInfo<Value>& args) {
Uint32::New(env->isolate(), 0),
v8::ReadOnly);
- assert(args[1]->IsObject());
+ CHECK(args[1]->IsObject());
Local<Object> internal = args[1].As<Object>();
ASSERT(internal->IsObject());