Skip to content
Snippets Groups Projects
Commit 7d20dee5 authored by Thomas Jahns's avatar Thomas Jahns :cartwheel: Committed by Sergey Kosukhin
Browse files

Switch to staged dynamic allocation of struct.

parent df0e5259
No related branches found
No related tags found
2 merge requests!34Version 2.2.0,!13Consolidation with CDI-PIO (develop)
......@@ -42,8 +42,8 @@ initAFiledataFileWriteAtAll(const char *filename, size_t bs)
MPI_Comm commPio = commInqCommPio();
int sizePio = commInqSizePio();
size_t nameSize = strlen(filename) + 1;
struct fileMPIFWAA *of = Malloc(sizeof(*of) + sizeof(of->collWriteSize[0]) * (size_t) sizePio + nameSize);
of->name = (char *) ((unsigned char *) of + sizeof(*of) + sizeof(of->collWriteSize[0]) * (size_t) sizePio);
struct fileMPIFWAA *of = Malloc(sizeof(*of) + sizeof(of->collWriteSize[0]) * (size_t) sizePio);
of->name = Malloc(nameSize);
memcpy(of->name, filename, nameSize);
MPI_Info open_info = MPI_INFO_NULL;
......@@ -81,7 +81,8 @@ destroyAFiledataFileWriteAtAll(void *v)
xmpi(MPI_Allreduce(MPI_IN_PLACE, &trailingOctets, 1, MPI_INT, MPI_LOR, commPio));
if (trailingOctets) xmpi(MPI_File_set_size(of->fh, endpos));
int iret = MPI_File_close(&of->fh);
Free(of->name);
of->name = NULL;
Free(of);
return iret == MPI_SUCCESS ? 0 : -1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment