N
Newsgroup Posting ID
i'm new to c and have gotten my program to run but by passing hardcoded
array sizes through the routines, i want to make the array extendable by
using realloc but i'd be doing it two routines down, i need to figure out
how to pass the array such that i know how many elements are in it before i
realloc and that the array gets passed back up the routines in tact. i've
used sizeof but it only works in the first routine, the 2nd and 3rd routines
result in a size of 4 (presumably the size of the pointer to the array) and
how would i free the realloc'd memory?
if anyone has any ideas it would be appreciated.
thanks
cut down versions below
int IsSMTP( void ) //main routine
{
char Routine[] = "IsSMTP";
BOOL ReturnValue = FALSE;
int TagFieldCount = 1;
char TagField[MAX_ARRAY][MAXENVVALUE];
// build the tag field array
TagFieldCount = BuildArrayFLD( TagField, "SMTP" );
return( ReturnValue);
}
int BuildArrayFLD( char Array[MAX_ARRAY][MAXENVVALUE], char *BuildCategory )
//called by issmtp
{
char Routine[] = "BuildArrayFLD";
int ReturnValue = 0;
char BuildView[] = "BFLD";
char BuildField[] = "server";
ReturnValue = BuildArrayFromViewCategory( Array, BuildView, BuildCategory,
MAX_FLD, BuildField );
return( ReturnValue );
}
int BuildArrayFromViewCategory( char Array[MAX_ARRAY][MAXENVVALUE], char
*ViewName, char *Category, int ArrayMax, char *FieldName )
{
char Routine[] = "BuildArrayFromViewCategory";
//this is where the array values are currently set and it would be where it
would be extended via realloc
}
array sizes through the routines, i want to make the array extendable by
using realloc but i'd be doing it two routines down, i need to figure out
how to pass the array such that i know how many elements are in it before i
realloc and that the array gets passed back up the routines in tact. i've
used sizeof but it only works in the first routine, the 2nd and 3rd routines
result in a size of 4 (presumably the size of the pointer to the array) and
how would i free the realloc'd memory?
if anyone has any ideas it would be appreciated.
thanks
cut down versions below
int IsSMTP( void ) //main routine
{
char Routine[] = "IsSMTP";
BOOL ReturnValue = FALSE;
int TagFieldCount = 1;
char TagField[MAX_ARRAY][MAXENVVALUE];
// build the tag field array
TagFieldCount = BuildArrayFLD( TagField, "SMTP" );
return( ReturnValue);
}
int BuildArrayFLD( char Array[MAX_ARRAY][MAXENVVALUE], char *BuildCategory )
//called by issmtp
{
char Routine[] = "BuildArrayFLD";
int ReturnValue = 0;
char BuildView[] = "BFLD";
char BuildField[] = "server";
ReturnValue = BuildArrayFromViewCategory( Array, BuildView, BuildCategory,
MAX_FLD, BuildField );
return( ReturnValue );
}
int BuildArrayFromViewCategory( char Array[MAX_ARRAY][MAXENVVALUE], char
*ViewName, char *Category, int ArrayMax, char *FieldName )
{
char Routine[] = "BuildArrayFromViewCategory";
//this is where the array values are currently set and it would be where it
would be extended via realloc
}