diff --git a/examples/main.c b/examples/main.c index 32ed12bfcc2fc7c1c0400c348a8222e2d6b86d0c..6244a7bb615d2a29002625a4ca233aec7ab11eeb 100644 --- a/examples/main.c +++ b/examples/main.c @@ -432,7 +432,8 @@ int main(int argc, char *argv[]) { } /* Read the parameter file */ - struct swift_params *params = (struct swift_params *)malloc(sizeof(struct swift_params)); + struct swift_params *params = + (struct swift_params *)malloc(sizeof(struct swift_params)); if (params == NULL) error("Error allocating memory for the parameter file."); if (myrank == 0) { message("Reading runtime parameters from file '%s'", paramFileName); diff --git a/src/align.h b/src/align.h index 35b7f0848f4901b65f5580adf2f14bb6dc13e387..243557ee0b4c6c0ae6d7ee75d92c50ec5e3b2f4a 100644 --- a/src/align.h +++ b/src/align.h @@ -49,11 +49,11 @@ * @param alignment The alignment in bytes of the array. */ #if defined(__ICC) -#define swift_align_information(type, array, alignment) \ +#define swift_align_information(type, array, alignment) \ __assume_aligned(array, alignment); #elif defined(__GNUC__) -#define swift_align_information(type, array, alignment) \ - array = (type *)__builtin_assume_aligned(array, alignment); +#define swift_align_information(type, array, alignment) \ + array = (type *)__builtin_assume_aligned(array, alignment); #else #define swift_align_information(array, alignment) ; #endif diff --git a/src/common_io.c b/src/common_io.c index 77bb403d19db0e911540124bb109f2c853028756..22e5fd9289cdca52435c001be7a26105b9e5ca80 100644 --- a/src/common_io.c +++ b/src/common_io.c @@ -418,7 +418,7 @@ void io_copy_mapper(void* restrict temp, int N, void* restrict extra_data) { const size_t copySize = typeSize * props.dimension; /* How far are we with this chunk? */ - char* restrict temp_c = (char *)temp; + char* restrict temp_c = (char*)temp; const ptrdiff_t delta = (temp_c - props.start_temp_c) / copySize; for (int k = 0; k < N; k++) { @@ -440,7 +440,7 @@ void io_convert_part_f_mapper(void* restrict temp, int N, const size_t dim = props.dimension; /* How far are we with this chunk? */ - float* restrict temp_f = (float *)temp; + float* restrict temp_f = (float*)temp; const ptrdiff_t delta = (temp_f - props.start_temp_f) / dim; for (int i = 0; i < N; i++) @@ -460,7 +460,7 @@ void io_convert_part_d_mapper(void* restrict temp, int N, const size_t dim = props.dimension; /* How far are we with this chunk? */ - double* restrict temp_d = (double *)temp; + double* restrict temp_d = (double*)temp; const ptrdiff_t delta = (temp_d - props.start_temp_d) / dim; for (int i = 0; i < N; i++) @@ -480,7 +480,7 @@ void io_convert_gpart_f_mapper(void* restrict temp, int N, const size_t dim = props.dimension; /* How far are we with this chunk? */ - float* restrict temp_f = (float *)temp; + float* restrict temp_f = (float*)temp; const ptrdiff_t delta = (temp_f - props.start_temp_f) / dim; for (int i = 0; i < N; i++) @@ -500,7 +500,7 @@ void io_convert_gpart_d_mapper(void* restrict temp, int N, const size_t dim = props.dimension; /* How far are we with this chunk? */ - double* restrict temp_d = (double *)temp; + double* restrict temp_d = (double*)temp; const ptrdiff_t delta = (temp_d - props.start_temp_d) / dim; for (int i = 0; i < N; i++) @@ -531,7 +531,7 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, if (props.conversion == 0) { /* No conversion */ /* Prepare some parameters */ - char* temp_c = (char *)temp; + char* temp_c = (char*)temp; props.start_temp_c = temp_c; /* Copy the whole thing into a buffer */ @@ -543,8 +543,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, if (props.convert_part_f != NULL) { /* Prepare some parameters */ - float* temp_f = (float *)temp; - props.start_temp_f = (float *)temp; + float* temp_f = (float*)temp; + props.start_temp_f = (float*)temp; props.e = e; /* Copy the whole thing into a buffer */ @@ -555,8 +555,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, } else if (props.convert_part_d != NULL) { /* Prepare some parameters */ - double* temp_d = (double *)temp; - props.start_temp_d = (double *)temp; + double* temp_d = (double*)temp; + props.start_temp_d = (double*)temp; props.e = e; /* Copy the whole thing into a buffer */ @@ -567,8 +567,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, } else if (props.convert_gpart_f != NULL) { /* Prepare some parameters */ - float* temp_f = (float *)temp; - props.start_temp_f = (float *)temp; + float* temp_f = (float*)temp; + props.start_temp_f = (float*)temp; props.e = e; /* Copy the whole thing into a buffer */ @@ -579,8 +579,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, } else if (props.convert_gpart_d != NULL) { /* Prepare some parameters */ - double* temp_d = (double *)temp; - props.start_temp_d = (double *)temp; + double* temp_d = (double*)temp; + props.start_temp_d = (double*)temp; props.e = e; /* Copy the whole thing into a buffer */ @@ -601,10 +601,12 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, /* message("Converting ! factor=%e", factor); */ if (io_is_double_precision(props.type)) { - swift_declare_aligned_ptr(double, temp_d, (double *)temp, IO_BUFFER_ALIGNMENT); + swift_declare_aligned_ptr(double, temp_d, (double*)temp, + IO_BUFFER_ALIGNMENT); for (size_t i = 0; i < num_elements; ++i) temp_d[i] *= factor; } else { - swift_declare_aligned_ptr(float, temp_f, (float *)temp, IO_BUFFER_ALIGNMENT); + swift_declare_aligned_ptr(float, temp_f, (float*)temp, + IO_BUFFER_ALIGNMENT); for (size_t i = 0; i < num_elements; ++i) temp_f[i] *= factor; } } diff --git a/src/engine.c b/src/engine.c index 038fc49baaed1ae445a9b3079d216768fc70cab4..973a5f4233c8b3a2eb49f2a4245ac791ace8e4dd 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2070,7 +2070,8 @@ void engine_exchange_proxy_multipoles(struct engine *e) { /* Also allocate the MPI requests */ const int count_requests = count_send_requests + count_recv_requests; - MPI_Request *requests = (MPI_Request *)malloc(sizeof(MPI_Request) * count_requests); + MPI_Request *requests = + (MPI_Request *)malloc(sizeof(MPI_Request) * count_requests); if (requests == NULL) error("Unable to allocate memory for MPI requests"); int this_request = 0; @@ -2311,7 +2312,8 @@ void engine_make_self_gravity_tasks(struct engine *e) { task_subtype_none, 0, 0, NULL, NULL); /* Create a grid of ghosts to deal with the dependencies */ - if ((ghosts = (struct task **)malloc(n_ghosts * sizeof(struct task *))) == 0) + if ((ghosts = (struct task **)malloc(n_ghosts * sizeof(struct task *))) == + 0) error("Error allocating memory for gravity fft ghosts"); /* Make the ghosts implicit and add the dependencies */ @@ -3022,7 +3024,8 @@ void engine_maketasks(struct engine *e) { e->size_links += s->tot_cells * self_grav_tasks_per_cell; /* Allocate the new list */ - if ((e->links = (struct link *)malloc(sizeof(struct link) * e->size_links)) == NULL) + if ((e->links = (struct link *)malloc(sizeof(struct link) * e->size_links)) == + NULL) error("Failed to allocate cell-task links."); e->nr_links = 0; @@ -5848,7 +5851,8 @@ void engine_struct_restore(struct engine *e, FILE *stream) { e->s = s; s->e = e; - struct unit_system *us = (struct unit_system *)malloc(sizeof(struct unit_system)); + struct unit_system *us = + (struct unit_system *)malloc(sizeof(struct unit_system)); units_struct_restore(us, stream); e->internal_units = us; @@ -5857,16 +5861,19 @@ void engine_struct_restore(struct engine *e, FILE *stream) { e->snapshotUnits = us; #ifdef WITH_MPI - struct repartition *reparttype = (struct repartition *)malloc(sizeof(struct repartition)); + struct repartition *reparttype = + (struct repartition *)malloc(sizeof(struct repartition)); partition_struct_restore(reparttype, stream); e->reparttype = reparttype; #endif - struct phys_const *physical_constants = (struct phys_const *)malloc(sizeof(struct phys_const)); + struct phys_const *physical_constants = + (struct phys_const *)malloc(sizeof(struct phys_const)); phys_const_struct_restore(physical_constants, stream); e->physical_constants = physical_constants; - struct hydro_props *hydro_properties = (struct hydro_props *)malloc(sizeof(struct hydro_props)); + struct hydro_props *hydro_properties = + (struct hydro_props *)malloc(sizeof(struct hydro_props)); hydro_props_struct_restore(hydro_properties, stream); e->hydro_properties = hydro_properties; @@ -5881,15 +5888,18 @@ void engine_struct_restore(struct engine *e, FILE *stream) { e->external_potential = external_potential; struct cooling_function_data *cooling_func = - (struct cooling_function_data *)malloc(sizeof(struct cooling_function_data)); + (struct cooling_function_data *)malloc( + sizeof(struct cooling_function_data)); cooling_struct_restore(cooling_func, stream); e->cooling_func = cooling_func; - struct sourceterms *sourceterms = (struct sourceterms *)malloc(sizeof(struct sourceterms)); + struct sourceterms *sourceterms = + (struct sourceterms *)malloc(sizeof(struct sourceterms)); sourceterms_struct_restore(sourceterms, stream); e->sourceterms = sourceterms; - struct swift_params *parameter_file = (struct swift_params *)malloc(sizeof(struct swift_params)); + struct swift_params *parameter_file = + (struct swift_params *)malloc(sizeof(struct swift_params)); parser_struct_restore(parameter_file, stream); e->parameter_file = parameter_file; diff --git a/src/parallel_io.c b/src/parallel_io.c index df2fc35768a58971e429e089530276c2e9bea018..315c187e65f1a30b0401cb9368944f8f9968223a 100644 --- a/src/parallel_io.c +++ b/src/parallel_io.c @@ -128,16 +128,16 @@ void readArray_chunk(hid_t h_data, hid_t h_plist_id, /* message("Converting ! factor=%e", factor); */ if (io_is_double_precision(props.type)) { - double* temp_d = (double *)temp; + double* temp_d = (double*)temp; for (size_t i = 0; i < num_elements; ++i) temp_d[i] *= factor; } else { - float* temp_f = (float *)temp; + float* temp_f = (float*)temp; for (size_t i = 0; i < num_elements; ++i) temp_f[i] *= factor; } } /* Copy temporary buffer to particle data */ - char* temp_c = (char *)temp; + char* temp_c = (char*)temp; for (size_t i = 0; i < N; ++i) memcpy(props.field + i * props.partSize, &temp_c[i * copySize], copySize); @@ -640,7 +640,8 @@ void read_ic_parallel(char* fileName, const struct unit_system* internal_units, H5Gclose(h_grp); /* Read the unit system used in the ICs */ - struct unit_system* ic_units = (struct unit_system *)malloc(sizeof(struct unit_system)); + struct unit_system* ic_units = + (struct unit_system*)malloc(sizeof(struct unit_system)); if (ic_units == NULL) error("Unable to allocate memory for IC unit system"); io_read_unit_system(h_file, ic_units, mpi_rank); diff --git a/src/partition.c b/src/partition.c index 6c9927d8cde5041caa932c6d688bdf3d5f3f7e59..8203c255d484672254b249042db22f5952579b4e 100644 --- a/src/partition.c +++ b/src/partition.c @@ -442,7 +442,8 @@ static void pick_metis(struct space *s, int nregions, double *vertexw, * of old and new ranks. Each element of the array has a cell count and * an unique index so we can sort into decreasing counts. */ int indmax = nregions * nregions; - struct indexval *ivs = (struct indexval *)malloc(sizeof(struct indexval) * indmax); + struct indexval *ivs = + (struct indexval *)malloc(sizeof(struct indexval) * indmax); bzero(ivs, sizeof(struct indexval) * indmax); for (int k = 0; k < ncells; k++) { int index = regionid[k] + nregions * s->cells_top[k].nodeID; diff --git a/src/proxy.c b/src/proxy.c index d035a206578c9becf8634ea4a4c9011ba1e144dd..10df8d191db992bdd26b39cd18e950f41c4690b3 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -145,7 +145,8 @@ void proxy_addcell_in(struct proxy *p, struct cell *c, int type) { p->size_cells_in *= proxy_buffgrow; struct cell **temp_cell; - if ((temp_cell = (struct cell **)malloc(sizeof(struct cell *) * p->size_cells_in)) == NULL) + if ((temp_cell = (struct cell **)malloc(sizeof(struct cell *) * + p->size_cells_in)) == NULL) error("Failed to allocate incoming cell list."); memcpy(temp_cell, p->cells_in, sizeof(struct cell *) * p->nr_cells_in); free(p->cells_in); @@ -190,7 +191,8 @@ void proxy_addcell_out(struct proxy *p, struct cell *c, int type) { p->size_cells_out *= proxy_buffgrow; struct cell **temp_cell; - if ((temp_cell = (struct cell **)malloc(sizeof(struct cell *) * p->size_cells_out)) == NULL) + if ((temp_cell = (struct cell **)malloc(sizeof(struct cell *) * + p->size_cells_out)) == NULL) error("Failed to allocate outgoing cell list."); memcpy(temp_cell, p->cells_out, sizeof(struct cell *) * p->nr_cells_out); free(p->cells_out); diff --git a/src/restart.c b/src/restart.c index 26cbf7e8f4d4793b9e0d786449864645cf4c3b6c..952df783626630c36dab410900c417461de07c04 100644 --- a/src/restart.c +++ b/src/restart.c @@ -133,8 +133,9 @@ void restart_write(struct engine *e, const char *filename) { error("Failed to open restart file: %s (%s)", filename, strerror(errno)); /* Dump our signature and version. */ - restart_write_blocks((void *)SWIFT_RESTART_SIGNATURE, strlen(SWIFT_RESTART_SIGNATURE), - 1, stream, "signature", "SWIFT signature"); + restart_write_blocks((void *)SWIFT_RESTART_SIGNATURE, + strlen(SWIFT_RESTART_SIGNATURE), 1, stream, "signature", + "SWIFT signature"); restart_write_blocks((void *)package_version(), strlen(package_version()), 1, stream, "version", "SWIFT version"); diff --git a/src/runner_doiact_fft.c b/src/runner_doiact_fft.c index 05896f6205d58d6bb76332d5936b98d480412385..1bc3846531504087c1f696f8b3d8eeb6c88dfe71 100644 --- a/src/runner_doiact_fft.c +++ b/src/runner_doiact_fft.c @@ -194,12 +194,12 @@ void runner_do_grav_fft(struct runner* r, int timer) { #endif /* Allocates some memory for the density mesh */ - double* restrict rho = (double *)fftw_malloc(sizeof(double) * N * N * N); + double* restrict rho = (double*)fftw_malloc(sizeof(double) * N * N * N); if (rho == NULL) error("Error allocating memory for density mesh"); /* Allocates some memory for the mesh in Fourier space */ fftw_complex* restrict frho = - (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * N * N * (N_half + 1)); + (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * N * N * (N_half + 1)); if (frho == NULL) error("Error allocating memory for transform of density mesh"); diff --git a/src/runner_doiact_grav.h b/src/runner_doiact_grav.h index bb54d9473e445a7b498ca6334dfc6ad670782e02..0bc7b851c05e94974ef6337ba3d8df5e5420c9a1 100644 --- a/src/runner_doiact_grav.h +++ b/src/runner_doiact_grav.h @@ -208,10 +208,10 @@ static INLINE void runner_dopair_grav_pp_full(const struct engine *e, float a_x = 0.f, a_y = 0.f, a_z = 0.f; /* Make the compiler understand we are in happy vectorization land */ - swift_align_information(float,cj_cache->x, SWIFT_CACHE_ALIGNMENT); - swift_align_information(float,cj_cache->y, SWIFT_CACHE_ALIGNMENT); - swift_align_information(float,cj_cache->z, SWIFT_CACHE_ALIGNMENT); - swift_align_information(float,cj_cache->m, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, cj_cache->x, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, cj_cache->y, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, cj_cache->z, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, cj_cache->m, SWIFT_CACHE_ALIGNMENT); swift_assume_size(gcount_padded_j, VEC_SIZE); /* Loop over every particle in the other cell. */ @@ -299,10 +299,10 @@ static INLINE void runner_dopair_grav_pp_truncated( float a_x = 0.f, a_y = 0.f, a_z = 0.f; /* Make the compiler understand we are in happy vectorization land */ - swift_align_information(float,cj_cache->x, SWIFT_CACHE_ALIGNMENT); - swift_align_information(float,cj_cache->y, SWIFT_CACHE_ALIGNMENT); - swift_align_information(float,cj_cache->z, SWIFT_CACHE_ALIGNMENT); - swift_align_information(float,cj_cache->m, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, cj_cache->x, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, cj_cache->y, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, cj_cache->z, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, cj_cache->m, SWIFT_CACHE_ALIGNMENT); swift_assume_size(gcount_padded_j, VEC_SIZE); /* Loop over every particle in the other cell. */ @@ -686,10 +686,10 @@ void runner_doself_grav_pp_full(struct runner *r, struct cell *c) { float a_x = 0.f, a_y = 0.f, a_z = 0.f; /* Make the compiler understand we are in happy vectorization land */ - swift_align_information(float,ci_cache->x, SWIFT_CACHE_ALIGNMENT); - swift_align_information(float,ci_cache->y, SWIFT_CACHE_ALIGNMENT); - swift_align_information(float,ci_cache->z, SWIFT_CACHE_ALIGNMENT); - swift_align_information(float,ci_cache->m, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, ci_cache->x, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, ci_cache->y, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, ci_cache->z, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, ci_cache->m, SWIFT_CACHE_ALIGNMENT); swift_assume_size(gcount_padded, VEC_SIZE); /* Loop over every other particle in the cell. */ @@ -812,10 +812,10 @@ void runner_doself_grav_pp_truncated(struct runner *r, struct cell *c) { float a_x = 0.f, a_y = 0.f, a_z = 0.f; /* Make the compiler understand we are in happy vectorization land */ - swift_align_information(float,ci_cache->x, SWIFT_CACHE_ALIGNMENT); - swift_align_information(float,ci_cache->y, SWIFT_CACHE_ALIGNMENT); - swift_align_information(float,ci_cache->z, SWIFT_CACHE_ALIGNMENT); - swift_align_information(float,ci_cache->m, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, ci_cache->x, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, ci_cache->y, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, ci_cache->z, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float, ci_cache->m, SWIFT_CACHE_ALIGNMENT); swift_assume_size(gcount_padded, VEC_SIZE); /* Loop over every other particle in the cell. */ diff --git a/src/scheduler.c b/src/scheduler.c index b75c5f474a4c9998a06e1834acebada08198afcf..f9cfff5645c571a6bae1d0dc111766e2b2be1120 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -1463,7 +1463,8 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) { case task_type_recv: #ifdef WITH_MPI if (t->subtype == task_subtype_tend) { - t->buff = (struct pcell_step *)malloc(sizeof(struct pcell_step) * t->ci->pcell_size); + t->buff = (struct pcell_step *)malloc(sizeof(struct pcell_step) * + t->ci->pcell_size); err = MPI_Irecv( t->buff, t->ci->pcell_size * sizeof(struct pcell_step), MPI_BYTE, t->ci->nodeID, t->flags, MPI_COMM_WORLD, &t->req); @@ -1482,7 +1483,8 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) { err = MPI_Irecv(t->ci->sparts, t->ci->scount, spart_mpi_type, t->ci->nodeID, t->flags, MPI_COMM_WORLD, &t->req); } else if (t->subtype == task_subtype_multipole) { - t->buff = (struct gravity_tensors *)malloc(sizeof(struct gravity_tensors) * t->ci->pcell_size); + t->buff = (struct gravity_tensors *)malloc( + sizeof(struct gravity_tensors) * t->ci->pcell_size); err = MPI_Irecv( t->buff, sizeof(struct gravity_tensors) * t->ci->pcell_size, MPI_BYTE, t->ci->nodeID, t->flags, MPI_COMM_WORLD, &t->req); @@ -1500,7 +1502,8 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) { case task_type_send: #ifdef WITH_MPI if (t->subtype == task_subtype_tend) { - t->buff = (struct pcell_step *)malloc(sizeof(struct pcell_step) * t->ci->pcell_size); + t->buff = (struct pcell_step *)malloc(sizeof(struct pcell_step) * + t->ci->pcell_size); cell_pack_end_step(t->ci, (struct pcell_step *)t->buff); if ((t->ci->pcell_size * sizeof(struct pcell_step)) > s->mpi_message_limit) @@ -1538,7 +1541,8 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) { err = MPI_Issend(t->ci->sparts, t->ci->scount, spart_mpi_type, t->cj->nodeID, t->flags, MPI_COMM_WORLD, &t->req); } else if (t->subtype == task_subtype_multipole) { - t->buff = (struct gravity_tensors *)malloc(sizeof(struct gravity_tensors) * t->ci->pcell_size); + t->buff = (struct gravity_tensors *)malloc( + sizeof(struct gravity_tensors) * t->ci->pcell_size); cell_pack_multipoles(t->ci, (struct gravity_tensors *)t->buff); err = MPI_Isend( t->buff, t->ci->pcell_size * sizeof(struct gravity_tensors), diff --git a/src/single_io.c b/src/single_io.c index 0534094fb5b30d1b40dcd772a5ff9bebaa4799f2..4ba85c2b1b6970469b17ac2d475e297b848604c6 100644 --- a/src/single_io.c +++ b/src/single_io.c @@ -131,16 +131,16 @@ void readArray(hid_t h_grp, const struct io_props prop, size_t N, /* message("Converting ! factor=%e", factor); */ if (io_is_double_precision(prop.type)) { - double* temp_d = (double *)temp; + double* temp_d = (double*)temp; for (size_t i = 0; i < num_elements; ++i) temp_d[i] *= factor; } else { - float* temp_f = (float *)temp; + float* temp_f = (float*)temp; for (size_t i = 0; i < num_elements; ++i) temp_f[i] *= factor; } } /* Copy temporary buffer to particle data */ - char* temp_c = (char *)temp; + char* temp_c = (char*)temp; for (size_t i = 0; i < N; ++i) memcpy(prop.field + i * prop.partSize, &temp_c[i * copySize], copySize); @@ -387,7 +387,8 @@ void read_ic_single(char* fileName, const struct unit_system* internal_units, H5Gclose(h_grp); /* Read the unit system used in the ICs */ - struct unit_system* ic_units = (struct unit_system *)malloc(sizeof(struct unit_system)); + struct unit_system* ic_units = + (struct unit_system*)malloc(sizeof(struct unit_system)); if (ic_units == NULL) error("Unable to allocate memory for IC unit system"); io_read_unit_system(h_file, ic_units, 0); @@ -428,8 +429,8 @@ void read_ic_single(char* fileName, const struct unit_system* internal_units, /* Allocate memory to store SPH particles */ if (with_hydro) { *Ngas = N[swift_type_gas]; - if (posix_memalign((void **)parts, part_align, *Ngas * sizeof(struct part)) != - 0) + if (posix_memalign((void**)parts, part_align, + *Ngas * sizeof(struct part)) != 0) error("Error while allocating memory for SPH particles"); bzero(*parts, *Ngas * sizeof(struct part)); } @@ -437,7 +438,7 @@ void read_ic_single(char* fileName, const struct unit_system* internal_units, /* Allocate memory to store star particles */ if (with_stars) { *Nstars = N[swift_type_star]; - if (posix_memalign((void **)sparts, spart_align, + if (posix_memalign((void**)sparts, spart_align, *Nstars * sizeof(struct spart)) != 0) error("Error while allocating memory for star particles"); bzero(*sparts, *Nstars * sizeof(struct spart)); @@ -449,7 +450,7 @@ void read_ic_single(char* fileName, const struct unit_system* internal_units, *Ngparts = (with_hydro ? N[swift_type_gas] : 0) + N[swift_type_dark_matter] + (with_stars ? N[swift_type_star] : 0); - if (posix_memalign((void **)gparts, gpart_align, + if (posix_memalign((void**)gparts, gpart_align, *Ngparts * sizeof(struct gpart)) != 0) error("Error while allocating memory for gravity particles"); bzero(*gparts, *Ngparts * sizeof(struct gpart)); @@ -581,9 +582,8 @@ void write_output_single(struct engine* e, const char* baseName, /* Number of unassociated gparts */ const size_t Ndm = Ntot > 0 ? Ntot - (Ngas + Nstars) : 0; - long long N_total[swift_type_count] = {(long long)Ngas, - (long long)Ndm, 0, 0, - (long long)Nstars, 0}; + long long N_total[swift_type_count] = { + (long long)Ngas, (long long)Ndm, 0, 0, (long long)Nstars, 0}; /* File name */ char fileName[FILENAME_BUFFER_SIZE]; @@ -767,7 +767,7 @@ void write_output_single(struct engine* e, const char* baseName, case swift_type_dark_matter: /* Allocate temporary array */ - if (posix_memalign((void **)&dmparts, gpart_align, + if (posix_memalign((void**)&dmparts, gpart_align, Ndm * sizeof(struct gpart)) != 0) error("Error while allocating temporart memory for DM particles"); bzero(dmparts, Ndm * sizeof(struct gpart)); diff --git a/src/space.c b/src/space.c index 3460416126dba6d386317c5b353068e6b7f792d5..329526fe14e38220750903058bc5201ef7486f63 100644 --- a/src/space.c +++ b/src/space.c @@ -1346,8 +1346,8 @@ void space_parts_sort(struct space *s, int *ind, size_t N, int min, int max, sort_struct.xparts = s->xparts; sort_struct.ind = ind; sort_struct.stack_size = 2 * (max - min + 1) + 10 + s->e->nr_threads; - if ((sort_struct.stack = (struct qstack *) - malloc(sizeof(struct qstack) * sort_struct.stack_size)) == NULL) + if ((sort_struct.stack = (struct qstack *)malloc( + sizeof(struct qstack) * sort_struct.stack_size)) == NULL) error("Failed to allocate sorting stack."); for (unsigned int i = 0; i < sort_struct.stack_size; i++) sort_struct.stack[i].ready = 0; @@ -1530,8 +1530,8 @@ void space_sparts_sort(struct space *s, int *ind, size_t N, int min, int max, sort_struct.sparts = s->sparts; sort_struct.ind = ind; sort_struct.stack_size = 2 * (max - min + 1) + 10 + s->e->nr_threads; - if ((sort_struct.stack = (struct qstack *) - malloc(sizeof(struct qstack) * sort_struct.stack_size)) == NULL) + if ((sort_struct.stack = (struct qstack *)malloc( + sizeof(struct qstack) * sort_struct.stack_size)) == NULL) error("Failed to allocate sorting stack."); for (unsigned int i = 0; i < sort_struct.stack_size; i++) sort_struct.stack[i].ready = 0; @@ -1713,8 +1713,8 @@ void space_gparts_sort(struct space *s, int *ind, size_t N, int min, int max, sort_struct.gparts = s->gparts; sort_struct.ind = ind; sort_struct.stack_size = 2 * (max - min + 1) + 10 + s->e->nr_threads; - if ((sort_struct.stack = (struct qstack *) - malloc(sizeof(struct qstack) * sort_struct.stack_size)) == NULL) + if ((sort_struct.stack = (struct qstack *)malloc( + sizeof(struct qstack) * sort_struct.stack_size)) == NULL) error("Failed to allocate sorting stack."); for (unsigned int i = 0; i < sort_struct.stack_size; i++) sort_struct.stack[i].ready = 0;