Fix a memcpy size, new crashing realloc macro.
Former-commit-id: 87a5690ad2297f4062f1f8349838440599f7172e
This commit is contained in:
parent
cce4f15eac
commit
a51236e058
|
@ -21,6 +21,8 @@ void qpms_pr_debug_at_flf(const char *filename, unsigned int linenum,
|
||||||
|
|
||||||
#define QPMS_CRASHING_MALLOC(pointer, size) {(pointer) = malloc(size); if(!pointer) qpms_pr_debug_at_flf(__FILE__,__LINE__,__func__, "Allocation of %zd bytes for " #pointer " failed.", (size_t) (size));}
|
#define QPMS_CRASHING_MALLOC(pointer, size) {(pointer) = malloc(size); if(!pointer) qpms_pr_debug_at_flf(__FILE__,__LINE__,__func__, "Allocation of %zd bytes for " #pointer " failed.", (size_t) (size));}
|
||||||
|
|
||||||
|
#define QPMS_CRASHING_REALLOC(pointer, size) {(pointer) = realloc(pointer, size); if(!pointer) qpms_pr_debug_at_flf(__FILE__,__LINE__,__func__, "Rellocation of %zd bytes for " #pointer " failed.", (size_t) (size));}
|
||||||
|
|
||||||
#define QPMS_WTF qpms_pr_error_at_flf(__FILE__,__LINE__,__func__,"Unexpected error.")
|
#define QPMS_WTF qpms_pr_error_at_flf(__FILE__,__LINE__,__func__,"Unexpected error.")
|
||||||
|
|
||||||
#define QPMS_ENSURE_SUCCESS(x) {if(x) QPMS_WTF;}
|
#define QPMS_ENSURE_SUCCESS(x) {if(x) QPMS_WTF;}
|
||||||
|
|
|
@ -748,8 +748,9 @@ complex double *qpms_orbit_irrep_basis(size_t *basis_size,
|
||||||
check_norm_compat(bspec);
|
check_norm_compat(bspec);
|
||||||
const size_t n = bspec->n;
|
const size_t n = bspec->n;
|
||||||
const qpms_gmi_t N = ot->size;
|
const qpms_gmi_t N = ot->size;
|
||||||
if (target == NULL)
|
const bool newtarget = (target == NULL);
|
||||||
target = malloc(n*n*N*N*sizeof(complex double));
|
if (newtarget)
|
||||||
|
QPMS_CRASHING_MALLOC(target,n*n*N*N*sizeof(complex double));
|
||||||
if (target == NULL) abort();
|
if (target == NULL) abort();
|
||||||
memset(target, 0, n*n*N*N*sizeof(complex double));
|
memset(target, 0, n*n*N*N*sizeof(complex double));
|
||||||
|
|
||||||
|
@ -786,7 +787,8 @@ complex double *qpms_orbit_irrep_basis(size_t *basis_size,
|
||||||
if(s[bs] < SVD_ATOL) break;
|
if(s[bs] < SVD_ATOL) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(target, V_H, bs*N*n*n*sizeof(complex double));
|
memcpy(target, V_H, bs*N*n*sizeof(complex double));
|
||||||
|
if(newtarget) QPMS_CRASHING_REALLOC(target, bs*N*n*sizeof(complex double));
|
||||||
if(basis_size) *basis_size = bs;
|
if(basis_size) *basis_size = bs;
|
||||||
|
|
||||||
free(U);
|
free(U);
|
||||||
|
|
Loading…
Reference in New Issue