0
I have the following problem: I am creating a pointer and allocating memory in it, passing its reference to function, but when I read it in the function happens the error reported 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;
}
Calling for:
char *buffer = (char *)malloc(1024*(sizeof(char)));
//
// Le o arquivo IP
//
FileLer(buffer, "configIP.txt");
Young woman organized in this code there, to facilitate the reading of it.
– user28595
In the
GEDI_LCD_DrawString(5, FONT_HEIGHT*5, FONT_WIDTH*0.7, FONT_HEIGHT*0.7, "Erro! %d");
- That one%d
will not work because a parameter is missing.– Victor Stafusa
What is the purpose of
int b = strlen(texto);
if the variableb
will not be used for anything after and thestrlen
should not produce side effects?– Victor Stafusa
What documentation of
GEDI_FS_FileRead()
?– pmg
Victor Stafusa, I’ve noticed that, but he’s not falling for Isis, that’s not the problem, but thank you
– Lucas Fernandes
strange that when I do the same function using only local variables it works, but when I try the same by passing parameter it happens this
– Lucas Fernandes
Victor Stafusa, just to identify the problem.
– Lucas Fernandes
&texto
andtexto
are different things. The first has kindchar **
, the second has kindchar *
. The first points to a local variable to the functionFileLer()
, the second points to an external string.– pmg
I googled
GEDI_FS_FileSizeGet
,GEDI_FS_FileOpen
,GEDI_FS_FileRead
,GEDI_FS_FileClose
,GEDI_LCD_DrawString
,GEDI_CLOCK_Delay
andGEDI_FS_STORAGE_PUBLIC
- Many of these google has never heard of. The ones he knows point to a question you asked here in July and to websites that copied the content of your other question to republish. So I ask you: Where do these functions come from? Who made them? Where are they published? All the places that they appear on the internet that I found point to you, so tell us who besides yourself knows them.– Victor Stafusa
Ah yes, and looking for
GEDI FS
in google, came no relevant result. What bug is this?– Victor Stafusa
pmg, exactly that, I switched the &text by text and it worked, thank you. When working with pointers received by parameters and a little different
– Lucas Fernandes
Victor Stafusa, It’s part of an API of a piece of equipment that I use, just this one in the manual, I think, sorry
– Lucas Fernandes
@Lucasfernandes Just out of curiosity, what is this equipment? I am intrigued that there is an API of some equipment that is so obscure.
– Victor Stafusa
@Victor Stafusa, it’s a POS machine, you know? Those card readers
– Lucas Fernandes