M
Martin
Is clearing a structure the following way well defined in C89? The
structure ACTION contains no floating point or pointer members. Only
integral types. My thoughts concern the padding - can and should it be
altered?
typedef unsigned char Byte;
#define MAX_ACTIONS 10
/* ... */
void clear_actions(ACTION *acts)
{
Byte *pByte = (Byte *)acts;
Byte *limit;
limit = pByte + sizeof(ACTION) * MAX_ACTIONS; /* 1 beyond array */
for ( ; pByte < limit; pByte++)
*pByte = 0;
} /* clear_actions */
structure ACTION contains no floating point or pointer members. Only
integral types. My thoughts concern the padding - can and should it be
altered?
typedef unsigned char Byte;
#define MAX_ACTIONS 10
/* ... */
void clear_actions(ACTION *acts)
{
Byte *pByte = (Byte *)acts;
Byte *limit;
limit = pByte + sizeof(ACTION) * MAX_ACTIONS; /* 1 beyond array */
for ( ; pByte < limit; pByte++)
*pByte = 0;
} /* clear_actions */