Skip to content

Пестов Владимир Алексеевич#1

Open
BasedDepartment1 wants to merge 1 commit into
cppdevcourse:masterfrom
BasedDepartment1:master
Open

Пестов Владимир Алексеевич#1
BasedDepartment1 wants to merge 1 commit into
cppdevcourse:masterfrom
BasedDepartment1:master

Conversation

@BasedDepartment1

Copy link
Copy Markdown

No description provided.

@BasedDepartment1

Copy link
Copy Markdown
Author
; <<>> DiG 9.18.39-0ubuntu0.24.04.2-Ubuntu <<>> @127.0.0.1 -p 5300 my.cool.domain.ru A
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: RESERVED12, id: 10044
;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;my.cool.domain.ru.             IN      A

;; Query time: 1 msec
;; SERVER: 127.0.0.1#5300(127.0.0.1) (UDP)
;; WHEN: Thu Jan 22 10:06:37 MSK 2026
;; MSG SIZE  rcvd: 35

Comment thread dns.cpp
auto subsection_length = std::to_integer<size_t>(*data_ptr);
++data_ptr;

name.append((const char*)(data_ptr), subsection_length);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C-style касты и reinterpret_cast-ы очень часто ведут к нарушению правил strict aliasing. Правильно тут было бы сделать std::memcpy, компиляторы обычно это хорошо оптимизируют.

Comment thread dns.cpp
data_ptr += subsection_length;
}
++data_ptr;
question.name = name;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно было бы, пожалуй, обойтись без временного объекта

Comment thread dns.cpp
{
if (question.name[i] != '.')
{
++subsection_length;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вот это можно было бы вычислить через какой-нибудь из методов строки

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants