Code Room
Code reviewMedium
Question
Review this C packet-cloning code used in a forwarding fast path.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
typedef struct { uint8_t *payload; size_t len; } Packet; Packet clone_pkt(Packet src) { Packet dst = src; // copy fields dst.len = src.len; return dst; // share payload pointer} void handle(Packet p) { Packet c = clone_pkt(p); forward(&c); free(c.payload); free(p.payload);}Run or narrate your approach, then ask the coach.