fwrite fails (returns 0, perror gives "Bad address")
What are the possible reasons for such an error. File being written to is created without a problem.
But fwrite fails each time. 

I am porting from 32-bit little endian to 64-bit big endian.

The structure I am writing is

    struct Node 
    {
	uint8_t *a;
	uint32_t *b;
	uint32_t c;
	uint32_t d;
	uint32_t e;
	uint32_t f;		
	uint32_t g;	
	uint16_t h;	
	uint8_t	i;	
	uint8_t j;	
	uint8_t k[MAX];
	uint32_t (*l)[2];
	uint32_t m;	
	uint32_t n;

	Node() {
		memset(this, 0, sizeof(*this));
		l = NULL;
		a = (uint8_t*)calloc(N,1);
	}
	~Node() {
		free(a);
		free(b);
	}
};


The code writing the node is

    void push(void *ptr)
    {
	Node *node = (Node *) ptr;
	assert(fwrite(node, sizeof(Node), 1, fpw) == 1);
        free(node);
    }

fpw has a global scope.

When i tried to debug, I found that fwrite returns 0 and perror gives "Bad address" as the error.

Any suggestions would be appreciated.

Thanks



fwrite fails (returns 0, perror gives "Bad address")
===

What are the possible reasons for such an error. File being written to is created without a problem.
But fwrite fails each time. 

I am porting from 32-bit little endian to 64-bit big endian.

The structure I am writing is

    struct Node 
    {
	uint8_t *a;
	uint32_t *b;
	uint32_t c;
	uint32_t d;
	uint32_t e;
	uint32_t f;		
	uint32_t g;	
	uint16_t h;	
	uint8_t	i;	
	uint8_t j;	
	uint8_t k[MAX];
	uint32_t (*l)[2];
	uint32_t m;	
	uint32_t n;

	Node() {
		memset(this, 0, sizeof(*this));
		l = NULL;
		a = (uint8_t*)calloc(N,1);
	}
	~Node() {
		free(a);
		free(b);
	}
};


The code writing the node is

    void push(void *ptr)
    {
	Node *node = (Node *) ptr;
	assert(fwrite(node, sizeof(Node), 1, fpw) == 1);
        free(node);
    }

fpw has a global scope.

When i tried to debug, I found that fwrite returns 0 and perror gives "Bad address" as the error.

Any suggestions would be appreciated.

Thanks


