Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[squash] remove goto → inline error statements
  • Loading branch information
addaleax committed May 1, 2017
commit a65a5c3ede1c7fadc9a8be332c9cb95a9f5f2061
10 changes: 5 additions & 5 deletions src/string_bytes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,6 @@ MaybeLocal<Value> StringBytes::Encode(Isolate* isolate,
}

MaybeLocal<String> val;
char* out = nullptr;

switch (encoding) {
case BUFFER:
Expand All @@ -711,9 +710,8 @@ MaybeLocal<Value> StringBytes::Encode(Isolate* isolate,

case ASCII:
if (contains_non_ascii(buf, buflen)) {
out = node::UncheckedMalloc(buflen);
char* out = node::UncheckedMalloc(buflen);
if (out == nullptr) {
malloc_failed:
*error = SB_MALLOC_FAILED_ERROR;
return MaybeLocal<Value>();
}
Expand Down Expand Up @@ -741,7 +739,8 @@ MaybeLocal<Value> StringBytes::Encode(Isolate* isolate,
size_t dlen = base64_encoded_size(buflen);
char* dst = node::UncheckedMalloc(dlen);
if (dst == nullptr) {
goto malloc_failed;
*error = SB_MALLOC_FAILED_ERROR;
return MaybeLocal<Value>();
}

size_t written = base64_encode(buf, buflen, dst, dlen);
Expand All @@ -754,7 +753,8 @@ MaybeLocal<Value> StringBytes::Encode(Isolate* isolate,
size_t dlen = buflen * 2;
char* dst = node::UncheckedMalloc(dlen);
if (dst == nullptr) {
goto malloc_failed;
*error = SB_MALLOC_FAILED_ERROR;
return MaybeLocal<Value>();
}
size_t written = hex_encode(buf, buflen, dst, dlen);
CHECK_EQ(written, dlen);
Expand Down