Skip to content
Snippets Groups Projects
Commit 14aaa6d5 authored by Thomas Jahns's avatar Thomas Jahns :cartwheel:
Browse files

Convert pointer member to variable-length array member.

* Also do default initialization with memset, this ensures a file is not
  opened and immediately closed by one collector.
parent 1ac3c4b2
No related branches found
No related tags found
No related merge requests found
......@@ -47,8 +47,8 @@ typedef struct
{
long offset;
bool finished;
bool *nfinished;
int fileID;
bool nfinished[];
} bFiledataPF;
static int
......@@ -106,18 +106,12 @@ static bFiledataPF *
initBFiledataPF(int fileID, int nc)
{
bFiledataPF *bfd;
int i;
bfd = ( bFiledataPF * ) xmalloc ( sizeof ( bFiledataPF ));
memset ( bfd, 0, sizeof ( bFiledataPF ));
size_t bfdSize = sizeof (bFiledataPF) + nc * sizeof (bool);
bfd = xcalloc(1, bfdSize);
bfd->offset = 0;
bfd->finished = false;
bfd->nfinished = ( bool * ) xmalloc ( nc * sizeof ( bool ));
bfd->fileID = fileID;
for ( i = 0; i < nc; i++ )
*( bfd->nfinished + i ) = true;
return bfd;
}
......@@ -152,7 +146,6 @@ destroyBFiledataPF(void *v)
int iret = 0;
bFiledataPF *bfd = (bFiledataPF * ) v;
free ( bfd->nfinished );
free ( bfd );
return iret;
......@@ -210,8 +203,6 @@ void fpgPOSIXFPGUARDSENDRECV ( void )
bfd->fileID = iret;
}
*( bfd->nfinished + source ) = false;
xdebug("id=%d, command=%d ( %s ), send offset=%ld", rtag.id,
rtag.command, command2charP[rtag.command], bfd->offset);
......
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