I'm reading in pieces of a jpg captured from a udp stream and I have the following:
#define BUF_SIZ 1066
int main(int argc, char *argv[])
{
int ptr;
uint8_t buf[BUF_SIZ];
uint8_t jpg[BUF_SIZ * 256];
repeat:
//... Check if first packet
//... fill buf after finding first packet
// append buf array to jpg array passing header
memcpy(&jpg[ptr], &buf[46], numbytes - 46);
ptr += (numbytes - 46);
... check if last packet.
... goto repeat if not last packet
ending:
... process jpg array
This is working but I don't think it's right (I'm new to c) and I'm getting occasional random segfaults).
I'm doing other things in between packets so I need to finish capturing the package asap