Skip to content

Comments

Packet implementation for portability over binary transport protocols#13

Open
matheo-lucak wants to merge 9 commits intomasterfrom
feature-packet
Open

Packet implementation for portability over binary transport protocols#13
matheo-lucak wants to merge 9 commits intomasterfrom
feature-packet

Conversation

@matheo-lucak
Copy link
Collaborator

@matheo-lucak matheo-lucak commented Jun 17, 2021

There is around 10 complete unit tests, ready to be reviewed

@matheo-lucak matheo-lucak added the packet Packet related label Jun 17, 2021
@matheo-lucak matheo-lucak requested a review from theopomies June 17, 2021 16:32
@matheo-lucak matheo-lucak self-assigned this Jun 17, 2021
@matheo-lucak matheo-lucak linked an issue Jun 18, 2021 that may be closed by this pull request
@matheo-lucak matheo-lucak removed a link to an issue Jun 18, 2021
Copy link
Owner

@theopomies theopomies left a comment

Choose a reason for hiding this comment

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

Please also add newline at EOF, after that it LGTM

return PACKET_ERROR;
}
if (packet_can_read(packet, size) == false) {
set_error("packet_read: Not enought data to read.");
Copy link
Owner

Choose a reason for hiding this comment

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

No T here -> enough

include/packet.h Outdated
size_t size;
size_t read_pos;
size_t send_pos;
bool is_valid;
Copy link
Owner

Choose a reason for hiding this comment

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

Not necessary now that packet_status_t conveys the info

return status;
packet->data[packet->size] = '\0';
size_to_read = strlen(packet->data + packet->read_pos) + 1;
*data = malloc(size_to_read);
Copy link
Owner

Choose a reason for hiding this comment

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

realloc instead of malloc, if *data is NULL it is equivalent else it is better

packet_read_string_cut_on_delimiter(packet, delim, &size_to_read);
if (size_to_read == 0)
return PACKET_END_OF_PACKET;
*data = calloc(1, size_to_read + 1);
Copy link
Owner

Choose a reason for hiding this comment

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

Same, reallocarray

[UPDATE] packet_read_string: uses realloc to free given data if previously allocated.
@matheo-lucak matheo-lucak requested a review from theopomies June 24, 2021 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packet Packet related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants