I have the following problem: I'm creating a pointer and allocating memory in it, passing its reference to function, but when I read it in function the error occurs in the title.
Function:
void FileLer(char *texto, char *file)
{
//
// Retorno
//
int ret = 99;
//
// Handle
//
UINT FileHandleLer = 0;
//
// Tamanho do Buffer
//
UINT BufferLenLer = 0;
//
// Pega o tamanho do arquivo
//
GEDI_FS_FileSizeGet(file, 1, &BufferLenLer);
if(BufferLenLer > 0)
{
GEDI_LCD_DrawString(5, FONT_HEIGHT*5, FONT_WIDTH*0.7, FONT_HEIGHT*0.7, "File Ok! %d", BufferLenLer);
GEDI_CLOCK_Delay(1000);
}
else
{
GEDI_LCD_DrawString(5, FONT_HEIGHT*5, FONT_WIDTH*0.7, FONT_HEIGHT*0.7, "Erro! ");
GEDI_CLOCK_Delay(1000);
//
// Para a funcao
//
return;
}
//
// Abre um arquivo
//
ret = GEDI_FS_FileOpen(file, 3, GEDI_FS_STORAGE_PUBLIC, &FileHandleLer);
ret = GEDI_FS_FileRead(FileHandleLer, &texto, &BufferLenLer);
int b = strlen(texto); <<<<<< -- Linha com o erro
//
// Fecha o socket
//
ret = GEDI_FS_FileClose(FileHandleLer);
//
// Zera Variaveis
//
ret = 0;
FileHandleLer = 0;
BufferLenLer = 0;
}
Call:
char *buffer = (char *)malloc(1024*(sizeof(char)));
//
// Le o arquivo IP
//
FileLer(buffer, "configIP.txt");