Why not `memcpy(buf, ptr->data, ptr->length)`?