Exportable version of WizziLab's modem driver.
Diff: src/alp_payload.cpp
- Revision:
- 63:544a488a06d3
- Parent:
- 62:75d819d68e5f
- Child:
- 64:7c338f388d82
--- a/src/alp_payload.cpp Tue Sep 21 08:47:52 2021 +0000 +++ b/src/alp_payload.cpp Tue Sep 21 16:33:36 2021 +0000 @@ -860,36 +860,28 @@ alp_payload_t* alp_payload_parse(u8* p, int length) { - if (NULL == p) + u8* d; + int len; + alp_parsed_chunk_t r; + alp_payload_t* alp = NULL; + alp_payload_t* alp_new = NULL; + + while (length > 0) { - return NULL; - } - - if (length <= 0) - { - return NULL; + d = p; + len = (int)alp_parse_chunk(&p, &r); + + // Malloc payload + alp_new = alp_payload_new(len); + + // Fill payload + alp_new->len = len; + memcpy(alp_new->d, d, len); + + alp = alp_payload_append(alp, alp_new); + + length -= len; } - u8* d = p; - alp_parsed_chunk_t r; - int len; - alp_payload_t* alp; - - // Parse payload - len = (int)alp_parse_chunk(&p, &r); - - if (len <= 0) - { - return NULL; - } - - // Malloc payload - alp = alp_payload_new(len); - - // Fill payload - alp->len = len; - memcpy(alp->d, d, len); - - // parse next - return alp_payload_append(alp, alp_payload_parse(p, length - len)); + return alp; } \ No newline at end of file