Code Room
Code reviewHardcr-g171
Subject Use after freeLevel Senior–Staff~30 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this C dynamic-array append.

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.

Talk through your review
Code to reviewc
#include <stdlib.h> typedef struct { int *data; size_t len, cap; } Vec; int *vec_push(Vec *v, int value) {    if (v->len == v->cap) {        v->cap = v->cap ? v->cap * 2 : 4;        v->data = realloc(v->data, v->cap * sizeof(int));    }    v->data[v->len] = value;    return &v->data[v->len++];}
Run or narrate your approach, then ask the coach.