GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: reduce variable scope in cares_wrap.cc · nodejs/node@402867c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • cares_wrap.cc
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/cares_wrap.cc‎

Copy file name to clipboardExpand all lines: src/cares_wrap.cc
+5-7Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -429,17 +429,16 @@ void cares_wrap_hostent_cpy(struct hostent* dest, struct hostent* src) {
429429

430430
/* copy `h_aliases` */
431431
size_t alias_count;
432-
size_t cur_alias_length;
433432
for (alias_count = 0;
434433
src->h_aliases[alias_count] != nullptr;
435434
alias_count++) {
436435
}
437436

438437
dest->h_aliases = node::Malloc<char*>(alias_count + 1);
439438
for (size_t i = 0; i < alias_count; i++) {
440-
cur_alias_length = strlen(src->h_aliases[i]);
441-
dest->h_aliases[i] = node::Malloc(cur_alias_length + 1);
442-
memcpy(dest->h_aliases[i], src->h_aliases[i], cur_alias_length + 1);
439+
const size_t cur_alias_size = strlen(src->h_aliases[i]) + 1;
440+
dest->h_aliases[i] = node::Malloc(cur_alias_size);
441+
memcpy(dest->h_aliases[i], src->h_aliases[i], cur_alias_size);
443442
}
444443
dest->h_aliases[alias_count] = nullptr;
445444

@@ -1065,7 +1064,6 @@ int ParseSoaReply(Environment* env,
10651064
/* Can't use ares_parse_soa_reply() here which can only parse single record */
10661065
unsigned int ancount = cares_get_16bit(buf + 6);
10671066
unsigned char* ptr = buf + NS_HFIXEDSZ;
1068-
int rr_type, rr_len;
10691067
char* name;
10701068
char* rr_name;
10711069
long temp_len; // NOLINT(runtime/int)
@@ -1094,8 +1092,8 @@ int ParseSoaReply(Environment* env,
10941092
break;
10951093
}
10961094

1097-
rr_type = cares_get_16bit(ptr);
1098-
rr_len = cares_get_16bit(ptr + 8);
1095+
const int rr_type = cares_get_16bit(ptr);
1096+
const int rr_len = cares_get_16bit(ptr + 8);
10991097
ptr += NS_RRFIXEDSZ;
11001098

11011099
/* only need SOA */

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.