Packet implementation for portability over binary transport protocols#13
Open
matheo-lucak wants to merge 9 commits intomasterfrom
Open
Packet implementation for portability over binary transport protocols#13matheo-lucak wants to merge 9 commits intomasterfrom
matheo-lucak wants to merge 9 commits intomasterfrom
Conversation
…eed to implement read and write functions for each types [ADD] Simple criterion test. Needing more
… terminated byte for strings
…iple type combinations
[DEL] -g CFLAGS on compilation
…tring, and correctly moving the read_pos index. Adding some complete tests
Open
Open
theopomies
requested changes
Jun 18, 2021
Owner
theopomies
left a comment
There was a problem hiding this comment.
Please also add newline at EOF, after that it LGTM
src/packet/read.c
Outdated
| return PACKET_ERROR; | ||
| } | ||
| if (packet_can_read(packet, size) == false) { | ||
| set_error("packet_read: Not enought data to read."); |
include/packet.h
Outdated
| size_t size; | ||
| size_t read_pos; | ||
| size_t send_pos; | ||
| bool is_valid; |
Owner
There was a problem hiding this comment.
Not necessary now that packet_status_t conveys the info
src/packet/read_string.c
Outdated
| return status; | ||
| packet->data[packet->size] = '\0'; | ||
| size_to_read = strlen(packet->data + packet->read_pos) + 1; | ||
| *data = malloc(size_to_read); |
Owner
There was a problem hiding this comment.
realloc instead of malloc, if *data is NULL it is equivalent else it is better
src/packet/read_string_until.c
Outdated
| 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); |
[UPDATE] packet_read_string: uses realloc to free given data if previously allocated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There is around 10 complete unit tests, ready to be reviewed