Commit bd36c8ef authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Fuse filename memory with containing struct.

parent 97088e50
......@@ -24,7 +24,6 @@ extern double accumWait;
typedef struct
{
char *name;
size_t size;
struct dBuffer *db1;
struct dBuffer *db2;
......@@ -34,6 +33,7 @@ typedef struct
int fileID;
int tsID;
bool finished;
char name[];
} aFiledataM;
static queue_t *bibAFiledataM;
......@@ -53,9 +53,8 @@ static aFiledataM *initAFiledataMPINONB ( const char *filename, size_t bs )
int iret;
MPI_Comm commNode = commInqCommNode ();
of = xmalloc ( sizeof ( of[0] ));
of = xmalloc(sizeof (*of) + strlen(filename) + 1);
of->name = xmalloc(strlen(filename) + 1);
strcpy(of->name, filename);
of->size = bs;
of->db1 = NULL;
......@@ -112,7 +111,6 @@ int destroyAFiledataMPINONB ( void *v )
dbuffer_cleanup ( & ( of->db1 ));
dbuffer_cleanup ( & ( of->db2 ));
free ( of->name );
free ( of );
xdebug ( "IOPE%d: closed file, cleaned up, return",
......
......@@ -37,7 +37,6 @@ extern double accumWrite;
typedef struct
{
char *name;
size_t size;
struct dBuffer *fb;
struct aiocb *ctrlBlks;
......@@ -48,6 +47,7 @@ typedef struct
bool finished;
bool *nfinished;
int handle, fileID;
char name[];
} bFiledataPA;
static int
......@@ -69,10 +69,8 @@ initBFiledataPA(char *filename, size_t bs, int nc)
xdebug ( "filename=%s, buffersize=%zu, ncollectors=%d, nPrefetchStreams=%d",
filename, bs, nc, nPrefStreams );
bfd = xmalloc ( sizeof ( bfd[0] ));
bfd->name = xmalloc (( strlen ( filename ) + 1) * sizeof ( bfd->name[0] ));
strcpy ( bfd->name, filename );
bfd = xmalloc( sizeof (*bfd) + strlen(filename) + 1);
strcpy(bfd->name, filename);
bfd->size = bs;
if (( bfd->handle = open ( bfd->name, O_CREAT | O_WRONLY, 0666 )) == -1 )
......@@ -157,8 +155,7 @@ destroyBFiledataPA ( void *v )
free ( bfd->nfinished );
free ( bfd->ctrlBlks );
free ( bfd->name );
free ( bfd );
free(bfd);
xdebug("%s", "closed file and cleaned up, return");
......
......@@ -35,7 +35,6 @@ extern double accumWrite;
typedef struct
{
char *name;
size_t size;
struct dBuffer *db1;
struct dBuffer *db2;
......@@ -43,6 +42,7 @@ typedef struct
FILE *fp;
IO_Server_command command;
int tsID, fileID;
char name[];
} aFiledataPF;
static int
......@@ -81,10 +81,8 @@ static aFiledataPF *initAFiledataPF ( const char *key, size_t bs)
size_t len;
int iret;
afd = ( aFiledataPF * ) xmalloc ( sizeof ( aFiledataPF ));
memset ( afd, 0, sizeof ( aFiledataPF ));
len = strlen ( key );
afd->name = (char *)xmalloc(len + 1);
len = strlen(key);
afd = xcalloc(1, sizeof (*afd) + len + 1);
strcpy(afd->name, key);
afd->size = bs;
afd->tsID = 0;
......@@ -152,8 +150,7 @@ int destroyAFiledataPF ( void *v )
dbuffer_cleanup ( &( afd->db1 ));
dbuffer_cleanup ( &( afd->db2 ));
free ( afd->name );
free ( afd );
free(afd);
return iret;
}
......
......@@ -29,13 +29,13 @@ extern double accumWrite;
typedef struct
{
char *name;
size_t size;
struct dBuffer *fb;
FILE *fp;
int fileID;
bool finished;
bool *nfinished;
char name[];
} bFiledataP;
static int
......@@ -54,10 +54,8 @@ initBFiledataP(char *filename, size_t bs, int nc, int fileID)
xdebug ( "filename=%s, buffersize=%lu, ncollectors=%d", filename, bs, nc );
bfp = xmalloc ( sizeof ( bfp[0] ));
bfp->name = xmalloc (( strlen ( filename ) + 1 ) * sizeof ( bfp->name[0] ));
strcpy ( bfp->name, filename );
bfp = xmalloc(sizeof (*bfp) + strlen(filename) + 1);
strcpy(bfp->name, filename);
bfp->size = bs;
if (( bfp->fp = fopen ( filename, "w" )) == NULL )
......@@ -97,7 +95,6 @@ destroyBFiledataP(void *v)
dbuffer_cleanup ( &( bfp->fb ));
free ( bfp->name );
free ( bfp->nfinished );
free ( bfp );
......
......@@ -18,7 +18,6 @@ extern long initial_buffersize;
typedef struct
{
char *name;
size_t size;
struct dBuffer *db1;
struct dBuffer *db2;
......@@ -26,6 +25,7 @@ typedef struct
IO_Server_command command;
MPI_Request request;
int tsID, fileID;
char name[];
} remoteFileBuf;
static queue_t * bibRemoteFileBuf;
......@@ -45,11 +45,9 @@ initRemoteFileBuf(const char *filename, size_t bs)
xdebug ( "filename=%s, buffersize=%zu, in", filename, bs );
afp = xmalloc ( sizeof ( remoteFileBuf ));
len = strlen ( filename );
afp->name = xmalloc (( len + 1) * sizeof ( afp->name[0] ));
strcpy ( afp->name, filename );
len = strlen(filename);
afp = xmalloc(sizeof (remoteFileBuf) + len + 1);
strcpy(afp->name, filename);
afp->size = bs;
afp->tsID = 0;
......@@ -83,8 +81,7 @@ destroyRemoteFileBuf(void *v)
dbuffer_cleanup(&afp->db1);
dbuffer_cleanup(&afp->db2);
free ( afp->name );
free ( afp );
free(afp);
xdebug("%s", "cleaned up, return");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment