Code Room
Code reviewHard
Question
Review this C dynamic buffer grow routine.
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
int buf_grow(Buffer *b, size_t need) { size_t newcap = b->cap ? b->cap * 2 : 16; while (newcap < need) newcap *= 2; b->data = realloc(b->data, newcap); // grow in place if (!b->data) { free(b->data); return -1; } b->cap = newcap; return 0;}Run or narrate your approach, then ask the coach.