Ver Mensaje Individual
  #9 (permalink)  
Antiguo 18/12/2008, 04:24
allypooh19
 
Fecha de Ingreso: diciembre-2008
Mensajes: 5
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: Problemas con asignar memoria a estructuras

¿Pero tengo una duda, y como harias para liberar esa memoria?


typedef struct TransferOperations {
char ** fileNames;
int * operationsFiles;
}TransferOperations,*TransferOperationsPtr;

//Init the struc
TransferOperationsPtr transfer = (TransferOperationsPtr)calloc(1,sizeof(TransferOpe rations));
transfer->fileNames = (char *)calloc(MAX_FILES, sizeof(char));
transfer->operationsFiles = (int *)calloc(MAX_FILES, sizeof(int));


void deleteOperations(TransferOperationsPtr operations) {

free(operations->fileNames);
free(operations->operationsFiles);
free(operations);
}


Al metodo deleteOperations se le llama con un puntero a la estructura y el problema está en que da error justo cuando intento liberar memoria.
Uno de los motivos puede ser porque no he asignado correctamente la estructura y el otro motivo puede ser porque no se libera correctamente asi.

Muchas gracias