X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=src%2Flink%2FC%2Fagents%2Fc_wash.c;h=557464e5c498618d90fd81b23ee4a46ebd45e74b;hb=HEAD;hp=a5ab7162795f1ce7881286790f0057a19e0c5474;hpb=e9f0debda3ab1209ece73fd4edaaefe755b6ab2a;p=progcomp10.git diff --git a/src/link/C/agents/c_wash.c b/src/link/C/agents/c_wash.c index a5ab716..557464e 100644 --- a/src/link/C/agents/c_wash.c +++ b/src/link/C/agents/c_wash.c @@ -1,5 +1,5 @@ /* - * c_frechie.c + * c_wash.c * c-link-lib * * Created by Daniel Axtens on 22/04/10. @@ -32,10 +32,12 @@ gospel on the number of agents you're going to see. */ #define NUMBEROFAGENTSGUESS 100 +typedef char agentName[MAXAGENTNAMELEN]; + /* data for each instance of my agent */ typedef struct { /* The name of the n-th foe who has beaten us */ - char (*defeatingFoes)[MAXAGENTNAMELEN]; + agentName * defeatingFoes; /* The length of the array, and how far we are along it */ size_t foesLen; @@ -64,7 +66,7 @@ int haveLostTo( wash_data * me, char * foeName ) { void * Initialise( char * myName ) { wash_data * me = malloc( sizeof( wash_data ) ); - me->defeatingFoes = calloc( NUMBEROFAGENTSGUESS, sizeof( MAXAGENTNAMELEN*sizeof(char) ) ); + me->defeatingFoes = calloc( NUMBEROFAGENTSGUESS, sizeof( agentName ) ); me->foesLen = NUMBEROFAGENTSGUESS; me->foesCount = 0; @@ -159,7 +161,7 @@ void Results( void * this, char * foeName, int isInstigatedByYou, if (me->foesCount==me->foesLen) { /* double the array size. This should error check, but doesn't */ me->defeatingFoes = realloc( me->defeatingFoes, - me->foesLen*2*sizeof( MAXAGENTNAMELEN*sizeof(char) ) ); + me->foesLen*2*sizeof( agentName ) ); me->foesLen *= 2; } @@ -174,4 +176,4 @@ void Cleanup( void * this ) { wash_data * me = (wash_data *) this; free(me->defeatingFoes); free(me); -} \ No newline at end of file +}