Skip to content

Commit 51db48f

Browse files
bnoordhuisrvagg
authored andcommitted
src,tools: remove null sentinel from source array
PR-URL: #5418 Reviewed-By: Trevor Norris <[email protected]>
1 parent 03a5dab commit 51db48f

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

src/node_javascript.cc

+5-10
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
#include "env.h"
55
#include "env-inl.h"
66

7-
#include <string.h>
8-
#if !defined(_MSC_VER)
9-
#include <strings.h>
10-
#endif
11-
127
namespace node {
138

149
using v8::HandleScope;
@@ -26,13 +21,13 @@ Local<String> MainSource(Environment* env) {
2621
void DefineJavaScript(Environment* env, Local<Object> target) {
2722
HandleScope scope(env->isolate());
2823

29-
for (int i = 0; natives[i].name; i++) {
30-
if (natives[i].source != node_native) {
31-
Local<String> name = String::NewFromUtf8(env->isolate(), natives[i].name);
24+
for (auto native : natives) {
25+
if (native.source != node_native) {
26+
Local<String> name = String::NewFromUtf8(env->isolate(), native.name);
3227
Local<String> source =
3328
String::NewFromUtf8(
34-
env->isolate(), reinterpret_cast<const char*>(natives[i].source),
35-
NewStringType::kNormal, natives[i].source_len).ToLocalChecked();
29+
env->isolate(), reinterpret_cast<const char*>(native.source),
30+
NewStringType::kNormal, native.source_len).ToLocalChecked();
3631
target->Set(name, source);
3732
}
3833
}

tools/js2c.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,7 @@ def ReadMacros(lines):
207207
size_t source_len;
208208
};
209209
210-
static const struct _native natives[] = {
211-
212-
%(native_lines)s\
213-
214-
{ NULL, NULL, 0 } /* sentinel */
215-
216-
};
210+
static const struct _native natives[] = { %(native_lines)s };
217211
218212
}
219213
#endif

0 commit comments

Comments
 (0)