@@ -206,7 +206,7 @@ static Local<Array> HostentToAddresses(struct hostent* host) {
206
206
for (int i = 0 ; host->h_addr_list [i]; ++i) {
207
207
uv_inet_ntop (host->h_addrtype , host->h_addr_list [i], ip, sizeof (ip));
208
208
209
- Local<String> address = String::New ( ip);
209
+ Local<String> address = OneByteString (node_isolate, ip);
210
210
addresses->Set (Integer::New (i, node_isolate), address);
211
211
}
212
212
@@ -219,7 +219,7 @@ static Local<Array> HostentToNames(struct hostent* host) {
219
219
Local<Array> names = Array::New ();
220
220
221
221
for (int i = 0 ; host->h_aliases [i]; ++i) {
222
- Local<String> address = String::New ( host->h_aliases [i]);
222
+ Local<String> address = OneByteString (node_isolate, host->h_aliases [i]);
223
223
names->Set (Integer::New (i, node_isolate), address);
224
224
}
225
225
@@ -426,7 +426,7 @@ class QueryCnameWrap: public QueryWrap {
426
426
// A cname lookup always returns a single record but we follow the
427
427
// common API here.
428
428
Local<Array> result = Array::New (1 );
429
- result->Set (0 , String::New ( host->h_name ));
429
+ result->Set (0 , OneByteString (node_isolate, host->h_name ));
430
430
ares_free_hostent (host);
431
431
432
432
this ->CallOnComplete (result);
@@ -456,14 +456,18 @@ class QueryMxWrap: public QueryWrap {
456
456
}
457
457
458
458
Local<Array> mx_records = Array::New ();
459
- Local<String> exchange_symbol = String::NewSymbol (" exchange" );
460
- Local<String> priority_symbol = String::NewSymbol (" priority" );
459
+ Local<String> exchange_symbol =
460
+ FIXED_ONE_BYTE_STRING (node_isolate, " exchange" );
461
+ Local<String> priority_symbol =
462
+ FIXED_ONE_BYTE_STRING (node_isolate, " priority" );
463
+
461
464
int i = 0 ;
462
465
for (struct ares_mx_reply * mx_current = mx_start;
463
466
mx_current;
464
467
mx_current = mx_current->next ) {
465
468
Local<Object> mx_record = Object::New ();
466
- mx_record->Set (exchange_symbol, String::New (mx_current->host ));
469
+ mx_record->Set (exchange_symbol,
470
+ OneByteString (node_isolate, mx_current->host ));
467
471
mx_record->Set (priority_symbol,
468
472
Integer::New (mx_current->priority , node_isolate));
469
473
mx_records->Set (Integer::New (i++, node_isolate), mx_record);
@@ -528,7 +532,7 @@ class QueryTxtWrap: public QueryWrap {
528
532
529
533
struct ares_txt_reply *current = txt_out;
530
534
for (int i = 0 ; current; ++i, current = current->next ) {
531
- Local<String> txt = String::New ( reinterpret_cast < char *>( current->txt ) );
535
+ Local<String> txt = OneByteString (node_isolate, current->txt );
532
536
txt_records->Set (Integer::New (i, node_isolate), txt);
533
537
}
534
538
@@ -566,16 +570,22 @@ class QuerySrvWrap: public QueryWrap {
566
570
}
567
571
568
572
Local<Array> srv_records = Array::New ();
569
- Local<String> name_symbol = String::NewSymbol (" name" );
570
- Local<String> port_symbol = String::NewSymbol (" port" );
571
- Local<String> priority_symbol = String::NewSymbol (" priority" );
572
- Local<String> weight_symbol = String::NewSymbol (" weight" );
573
+ Local<String> name_symbol =
574
+ FIXED_ONE_BYTE_STRING (node_isolate, " name" );
575
+ Local<String> port_symbol =
576
+ FIXED_ONE_BYTE_STRING (node_isolate, " port" );
577
+ Local<String> priority_symbol =
578
+ FIXED_ONE_BYTE_STRING (node_isolate, " priority" );
579
+ Local<String> weight_symbol =
580
+ FIXED_ONE_BYTE_STRING (node_isolate, " weight" );
581
+
573
582
int i = 0 ;
574
583
for (struct ares_srv_reply * srv_current = srv_start;
575
584
srv_current;
576
585
srv_current = srv_current->next ) {
577
586
Local<Object> srv_record = Object::New ();
578
- srv_record->Set (name_symbol, String::New (srv_current->host ));
587
+ srv_record->Set (name_symbol,
588
+ OneByteString (node_isolate, srv_current->host ));
579
589
srv_record->Set (port_symbol,
580
590
Integer::New (srv_current->port , node_isolate));
581
591
srv_record->Set (priority_symbol,
@@ -620,12 +630,18 @@ class QueryNaptrWrap: public QueryWrap {
620
630
}
621
631
622
632
Local<Array> naptr_records = Array::New ();
623
- Local<String> flags_symbol = String::NewSymbol (" flags" );
624
- Local<String> service_symbol = String::NewSymbol (" service" );
625
- Local<String> regexp_symbol = String::NewSymbol (" regexp" );
626
- Local<String> replacement_symbol = String::NewSymbol (" replacement" );
627
- Local<String> order_symbol = String::NewSymbol (" order" );
628
- Local<String> preference_symbol = String::NewSymbol (" preference" );
633
+ Local<String> flags_symbol =
634
+ FIXED_ONE_BYTE_STRING (node_isolate, " flags" );
635
+ Local<String> service_symbol =
636
+ FIXED_ONE_BYTE_STRING (node_isolate, " service" );
637
+ Local<String> regexp_symbol =
638
+ FIXED_ONE_BYTE_STRING (node_isolate, " regexp" );
639
+ Local<String> replacement_symbol =
640
+ FIXED_ONE_BYTE_STRING (node_isolate, " replacement" );
641
+ Local<String> order_symbol =
642
+ FIXED_ONE_BYTE_STRING (node_isolate, " order" );
643
+ Local<String> preference_symbol =
644
+ FIXED_ONE_BYTE_STRING (node_isolate, " preference" );
629
645
630
646
int i = 0 ;
631
647
for (ares_naptr_reply* naptr_current = naptr_start;
@@ -634,13 +650,14 @@ class QueryNaptrWrap: public QueryWrap {
634
650
Local<Object> naptr_record = Object::New ();
635
651
636
652
naptr_record->Set (flags_symbol,
637
- String::New ( reinterpret_cast < char *>( naptr_current->flags ) ));
653
+ OneByteString (node_isolate, naptr_current->flags ));
638
654
naptr_record->Set (service_symbol,
639
- String::New ( reinterpret_cast < char *>( naptr_current->service ) ));
655
+ OneByteString (node_isolate, naptr_current->service ));
640
656
naptr_record->Set (regexp_symbol,
641
- String::New ( reinterpret_cast < char *>( naptr_current->regexp ) ));
657
+ OneByteString (node_isolate, naptr_current->regexp ));
642
658
naptr_record->Set (replacement_symbol,
643
- String::New (naptr_current->replacement ));
659
+ OneByteString (node_isolate,
660
+ naptr_current->replacement ));
644
661
naptr_record->Set (order_symbol, Integer::New (naptr_current->order ,
645
662
node_isolate));
646
663
naptr_record->Set (preference_symbol,
@@ -814,7 +831,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
814
831
continue ;
815
832
816
833
// Create JavaScript string
817
- Local<String> s = String::New ( ip);
834
+ Local<String> s = OneByteString (node_isolate, ip);
818
835
results->Set (n, s);
819
836
n++;
820
837
}
@@ -841,7 +858,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
841
858
continue ;
842
859
843
860
// Create JavaScript string
844
- Local<String> s = String::New ( ip);
861
+ Local<String> s = OneByteString (node_isolate, ip);
845
862
results->Set (n, s);
846
863
n++;
847
864
}
@@ -943,7 +960,7 @@ static void GetServers(const FunctionCallbackInfo<Value>& args) {
943
960
int err = uv_inet_ntop (cur->family , caddr, ip, sizeof (ip));
944
961
assert (err == 0 );
945
962
946
- Local<String> addr = String::New ( ip);
963
+ Local<String> addr = OneByteString (node_isolate, ip);
947
964
server_array->Set (i, addr);
948
965
}
949
966
@@ -1024,7 +1041,7 @@ static void SetServers(const FunctionCallbackInfo<Value>& args) {
1024
1041
static void StrError (const FunctionCallbackInfo<Value>& args) {
1025
1042
HandleScope scope (node_isolate);
1026
1043
const char * errmsg = ares_strerror (args[0 ]->Int32Value ());
1027
- args.GetReturnValue ().Set (String::New ( errmsg));
1044
+ args.GetReturnValue ().Set (OneByteString (node_isolate, errmsg));
1028
1045
}
1029
1046
1030
1047
@@ -1069,14 +1086,14 @@ static void Initialize(Handle<Object> target) {
1069
1086
NODE_SET_METHOD (target, " getServers" , GetServers);
1070
1087
NODE_SET_METHOD (target, " setServers" , SetServers);
1071
1088
1072
- target->Set (String::NewSymbol ( " AF_INET" ),
1089
+ target->Set (FIXED_ONE_BYTE_STRING (node_isolate, " AF_INET" ),
1073
1090
Integer::New (AF_INET, node_isolate));
1074
- target->Set (String::NewSymbol ( " AF_INET6" ),
1091
+ target->Set (FIXED_ONE_BYTE_STRING (node_isolate, " AF_INET6" ),
1075
1092
Integer::New (AF_INET6, node_isolate));
1076
- target->Set (String::NewSymbol ( " AF_UNSPEC" ),
1093
+ target->Set (FIXED_ONE_BYTE_STRING (node_isolate, " AF_UNSPEC" ),
1077
1094
Integer::New (AF_UNSPEC, node_isolate));
1078
1095
1079
- oncomplete_sym = String::New ( " oncomplete" );
1096
+ oncomplete_sym = FIXED_ONE_BYTE_STRING (node_isolate, " oncomplete" );
1080
1097
}
1081
1098
1082
1099
} // namespace cares_wrap
0 commit comments