trallallero
15-05-2007, 10:31
Ciao.
In una funzione del genere:
void prova( int* pCount, BYTE*** pppTest)
{
int i;
BYTE **pP = NULL;
*pCount = 10;
pP = (BYTE **)malloc( *pCount * sizeof(BYTE *) );
if ( ! pP )
puts( "error allocating memory 1"), exit(1);
for (i = 0; i < *pCount; i++)
{
pP[i] = (BYTE *)malloc( 128 * sizeof(BYTE) );
if ( !pP[i] )
puts("error allocating memory 2"), exit(1);
memset( pP[i], 0, 128 * sizeof(BYTE) );
sprintf(pP[i], "this is a test <%03i>", i );
}
*pppTest = pP;
return 0;
}
percheŽ non posso usare direttamente *pppTest anzicheŽ pP ?
CioeŽ, percheŽ devo dichiararmi un puntatore locale, allocare etc e poi alla fine assegnare lŽindirizzo a quello passato e non usare direttamente il puntatore che trovo nellŽindirizzo passato ?
EŽ un poŽ di giorni che lavoro con triplette *** e mi son perso un attimo :uh:
In una funzione del genere:
void prova( int* pCount, BYTE*** pppTest)
{
int i;
BYTE **pP = NULL;
*pCount = 10;
pP = (BYTE **)malloc( *pCount * sizeof(BYTE *) );
if ( ! pP )
puts( "error allocating memory 1"), exit(1);
for (i = 0; i < *pCount; i++)
{
pP[i] = (BYTE *)malloc( 128 * sizeof(BYTE) );
if ( !pP[i] )
puts("error allocating memory 2"), exit(1);
memset( pP[i], 0, 128 * sizeof(BYTE) );
sprintf(pP[i], "this is a test <%03i>", i );
}
*pppTest = pP;
return 0;
}
percheŽ non posso usare direttamente *pppTest anzicheŽ pP ?
CioeŽ, percheŽ devo dichiararmi un puntatore locale, allocare etc e poi alla fine assegnare lŽindirizzo a quello passato e non usare direttamente il puntatore che trovo nellŽindirizzo passato ?
EŽ un poŽ di giorni che lavoro con triplette *** e mi son perso un attimo :uh: