GeezerVison is showing github.com — string_bytes: export GetExternalParts · juliens/node@63fc6a6
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/string_bytes.cc +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -230,12 +230,13 @@ size_t hex_decode(char* buf, |
230 | 230 | } |
231 | 231 |
|
232 | 232 |
|
233 | | -bool GetExternalParts(Handle<Value> val, const char** data, size_t* len) { |
| 233 | +bool StringBytes::GetExternalParts(Handle<Value> val, |
| 234 | + const char** data, |
| 235 | + size_t* len) { |
234 | 236 | if (Buffer::HasInstance(val)) { |
235 | 237 | *data = Buffer::Data(val); |
236 | 238 | *len = Buffer::Length(val); |
237 | 239 | return true; |
238 | | - |
239 | 240 | } |
240 | 241 |
|
241 | 242 | assert(val->IsString()); |
|
Collapse file
Copy file name to clipboardExpand all lines: src/string_bytes.h +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -44,6 +44,12 @@ class StringBytes { |
44 | 44 | // very much slower for UTF-8 |
45 | 45 | static size_t Size(v8::Handle<v8::Value> val, enum encoding enc); |
46 | 46 |
|
| 47 | + // If the string is external then assign external properties to data and len, |
| 48 | + // then return true. If not return false. |
| 49 | + static bool GetExternalParts(v8::Handle<v8::Value> val, |
| 50 | + const char** data, |
| 51 | + size_t* len); |
| 52 | + |
47 | 53 | // Write the bytes from the string or buffer into the char* |
48 | 54 | // returns the number of bytes written, which will always be |
49 | 55 | // <= buflen. Use StorageSize/Size first to know how much |
|