我需要你的帮助!
我喜欢复制这样的结构:
typedef struct PackageObject_s {
long **vertex; // vertices
long num_vertex; // count of vertices
long objectType; //
REAL r; //
long bottom[3]; // bounding box bottom vector
long top[3]; // bounding box top vector
long *start; //
REAL coverage; //
} PackageObject __attribute__ ((aligned));
我这样尝试:
static inline void PackageObject_copy(PackageObject *dst, const PackageObject *src) {
dst->num_vertex = src->num_vertex;
dst->objectType = src->objectType;
dst->r = src->r;
vec_assign3l(dst->bottom, src->bottom);
vec_assign3l(dst->top, src->top);
// TODO copy **vertex ???
dst->coverage = src->coverage;
dst->coverage = src->coverage;
}
我该如何解决这个问题?
预先感谢您的帮助!!
更新 - 我的深度复制解决方案vertex
- 感谢所有帮助:
dst->vertex = (long *)malloc(dst->num_vertex * 3 * sizeof(long));
for (long i=0; i < src->num_vertex; i++) {
dst->vertex[i] = (long)malloc(3*sizeof(long));
memcpy(dst->vertex[i],src->vertex[i],3 * sizeof(long));
}