EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

sprintf function

Started by eran...@gmail.com May 14, 2008
Hi all,

I'm using the sprintf function like:
Result = sprintf(strFloat,"%3.3f",stInterpVars.fResult);

Where:
Result - number of copeid charectars.
strFloat - destination, type char[].
stInterpVars.fResult - source, type double.

The function is working, I got the correct result in destination, but there is a memory leak. The function overwrite other variable.

Does someone know what happend? or anyone handle with that function?
Thanks


OMAP35x EVM jump-starts low-power apps
The modular and extensible OMAP35x Evaluation Module (EVM) enables developers to start building applications based on the OMAP35x architecture: http://www.DSPRelated.com/omap35x
Are you sure the strFloat variable has enough space reserved ?
If you typedef as a char[], it means char*, so no memory allocated to your
string.

Veuillez rondre e...@gmail.com
Envoypar : c...
Pour : c...
cc :

Objet : [c28x] sprintf function

Hi all,

I'm using the sprintf function like:
Result = sprintf(strFloat,"%3.3f",stInterpVars.fResult);

Where:
Result - number of copeid charectars.
strFloat - destination, type char[].
stInterpVars.fResult - source, type double.

The function is working, I got the correct result in destination, but
there is a memory leak. The function overwrite other variable.

Does someone know what happend? or anyone handle with that function?
Thanks


OMAP35x EVM jump-starts low-power apps
The modular and extensible OMAP35x Evaluation Module (EVM) enables developers to start building applications based on the OMAP35x architecture: http://www.DSPRelated.com/omap35x
Hi,

I typed the strFloat as char[32], and the result i want to get is less then
10 charecters (%3.3f).
I know that the sprinf needs to allocate memory, and in my DSP/BIOS i'm not
using a heap.
Is the unprototype heap couse this problam?

Thanks.

On Fri, May 16, 2008 at 9:01 AM, Alain SALMETOZ
wrote:

> Are you sure the strFloat variable has enough space reserved ?
> If you typedef as a char[], it means char*, so no memory allocated to your
> string.
>
> Veuillez rondre e...@gmail.com
> Envoypar : c...
> Pour : c...
> cc :
>
> Objet : [c28x] sprintf function
>
> Hi all,
>
> I'm using the sprintf function like:
> Result = sprintf(strFloat,"%3.3f",stInterpVars.fResult);
>
> Where:
> Result - number of copeid charectars.
> strFloat - destination, type char[].
> stInterpVars.fResult - source, type double.
>
> The function is working, I got the correct result in destination, but
> there is a memory leak. The function overwrite other variable.
>
> Does someone know what happend? or anyone handle with that function?
> Thanks
>
yes, you need to allcoate from 0x100 to 0x300 words to heap to all
printf() function to work.

Pour : "Alain SALMETOZ"
cc : c...

Objet : Re: R. : [c28x] sprintf function

Hi,

I typed the strFloat as char[32], and the result i want to get is less
then 10 charecters (%3.3f).
I know that the sprinf needs to allocate memory, and in my DSP/BIOS i'm
not using a heap.
Is the unprototype heap couse this problam?

Thanks.

On Fri, May 16, 2008 at 9:01 AM, Alain SALMETOZ > wrote:
Are you sure the strFloat variable has enough space reserved ?
If you typedef as a char[], it means char*, so no memory allocated to your

string.

Veuillez rondre e...@gmail.com
Envoypar : c...
Pour : c...
cc :

Objet : [c28x] sprintf function
Hi all,

I'm using the sprintf function like:
Result = sprintf(strFloat,"%3.3f",stInterpVars.fResult);

Where:
Result - number of copeid charectars.
strFloat - destination, type char[].
stInterpVars.fResult - source, type double.

The function is working, I got the correct result in destination, but
there is a memory leak. The function overwrite other variable.

Does someone know what happend? or anyone handle with that function?
Thanks



OMAP35x EVM jump-starts low-power apps
The modular and extensible OMAP35x Evaluation Module (EVM) enables developers to start building applications based on the OMAP35x architecture: http://www.DSPRelated.com/omap35x
Unfortunately even when I add a 0x300 size of heap, the problem still
remain.
but as I said befor the function is working but I got a proble, with
different variable.

On Mon, May 19, 2008 at 9:26 AM, Alain SALMETOZ
wrote:

>
> yes, you need to allcoate from 0x100 to 0x300 words to heap to all printf()
> function to work.
> Pour : "Alain SALMETOZ"
> cc : c...
>
> Objet : Re: R. : [c28x] sprintf function
>
> Hi,
>
> I typed the strFloat as char[32], and the result i want to get is less then
> 10 charecters (%3.3f).
> I know that the sprinf needs to allocate memory, and in my DSP/BIOS i'm not
> using a heap.
> Is the unprototype heap couse this problam?
>
> Thanks.
>
> On Fri, May 16, 2008 at 9:01 AM, Alain SALMETOZ <*
> a...@mgeups.com* > wrote:
> Are you sure the strFloat variable has enough space reserved ?
> If you typedef as a char[], it means char*, so no memory allocated to your
> string.
>
> Veuillez rondre *e...@gmail.com*
> Envoypar : *c...*
> Pour : *c...*
> cc :
>
> Objet : [c28x] sprintf function
> Hi all,
>
> I'm using the sprintf function like:
> Result = sprintf(strFloat,"%3.3f",stInterpVars.fResult);
>
> Where:
> Result - number of copeid charectars.
> strFloat - destination, type char[].
> stInterpVars.fResult - source, type double.
>
> The function is working, I got the correct result in destination, but
> there is a memory leak. The function overwrite other variable.
>
> Does someone know what happend? or anyone handle with that function?
> Thanks
>
>
>

OMAP35x EVM jump-starts low-power apps
The modular and extensible OMAP35x Evaluation Module (EVM) enables developers to start building applications based on the OMAP35x architecture: http://www.DSPRelated.com/omap35x
Please, verify that you have assigned the esysmem section to a RAM block
as below.
Note : If you are using LARGE memory model, esysmem is used instead of
sysmem.

.esysmem : > EXTRAM2, PAGE = 1

>From documentation:
The .esysmem section is a uninitialized section that reserves space for
dynamic memory allocation.
The reserved space is used by far malloc functions.
If no far malloc functions are used, the size of the section remains 0.

Envoypar : c...
Pour : "Alain SALMETOZ"
cc : c...

Objet : Re: [c28x] sprintf function

Unfortunately even when I add a 0x300 size of heap, the problem still
remain.
but as I said befor the function is working but I got a proble, with
different variable.

On Mon, May 19, 2008 at 9:26 AM, Alain SALMETOZ

wrote:

>
> yes, you need to allcoate from 0x100 to 0x300 words to heap to all
printf()
> function to work.
> Pour : "Alain SALMETOZ"
> cc : c...
>
> Objet : Re: R. : [c28x] sprintf function
>
> Hi,
>
> I typed the strFloat as char[32], and the result i want to get is less
then
> 10 charecters (%3.3f).
> I know that the sprinf needs to allocate memory, and in my DSP/BIOS i'm
not
> using a heap.
> Is the unprototype heap couse this problam?
>
> Thanks.
>
> On Fri, May 16, 2008 at 9:01 AM, Alain SALMETOZ <*
> a...@mgeups.com* > wrote:
> Are you sure the strFloat variable has enough space reserved ?
> If you typedef as a char[], it means char*, so no memory allocated to
your
> string.
>
> Veuillez rondre *e...@gmail.com*
> Envoypar : *c...*
> Pour : *c...*
> cc :
>
> Objet : [c28x] sprintf function
> Hi all,
>
> I'm using the sprintf function like:
> Result = sprintf(strFloat,"%3.3f",stInterpVars.fResult);
>
> Where:
> Result - number of copeid charectars.
> strFloat - destination, type char[].
> stInterpVars.fResult - source, type double.
>
> The function is working, I got the correct result in destination, but
> there is a memory leak. The function overwrite other variable.
>
> Does someone know what happend? or anyone handle with that function?
> Thanks
>
>
>


OMAP35x EVM jump-starts low-power apps
The modular and extensible OMAP35x Evaluation Module (EVM) enables developers to start building applications based on the OMAP35x architecture: http://www.DSPRelated.com/omap35x
SECTIONS
{
/* Setup for "boot to SARAM" mode:
The codestart section (found in DSP28_CodeStartBranch.asm)
re-directs execution to the start of user code. */
/* codestart : > BEGIN, PAGE = 0*/
/*** User Defined Sections ***/
codestart :> BEGIN_M0, PAGE = 0 /* Used by file CodeStartBranch.asm */
ramfuncs :> L47SARAM PAGE = 0
.adc_cal :> L03SARAM PAGE = 0
SaramCode :> L47SARAM PAGE = 0
RecorderData :> L47SARAM PAGE = 0
RecorderCode :> SRAM PAGE = 0
IoCode :> SRAM PAGE = 0
IoData :> L47SARAM PAGE = 0
DmaCode :> L47SARAM PAGE = 0
DmaData :> L47SARAM PAGE = 0
ServoCode :> L03SARAM PAGE = 0
ServoData :> L03SARAM PAGE = 0
Servo2Code :> L47SARAM PAGE = 0
Servo2Data :> L47SARAM PAGE = 0
DMARAML4 :> L47SARAM PAGE = 0
SramCode :> SRAM PAGE = 0
LexCode :> SRAM PAGE = 0

CanIsrCode :> L03SARAM PAGE = 0
pECanaMboxesData :> L03SARAM PAGE = 0

SramData :> SRAMDATA PAGE = 1
/* SaramCode :> MSARAM PAGE = 1 */
}
SECTIONS
{
/* Setup for "boot to SARAM" mode:
The codestart section (found in DSP28_CodeStartBranch.asm)
re-directs execution to the start of user code. */
/* codestart : > BEGIN, PAGE = 0*/
/*** User Defined Sections ***/
codestart :> BEGIN_M0, PAGE = 0 /* Used by file CodeStartBranch.asm */
ramfuncs :> L47SARAM PAGE = 0
.adc_cal :> L03SARAM PAGE = 0
SaramCode :> L47SARAM PAGE = 0
RecorderData :> L47SARAM PAGE = 0
RecorderCode :> SRAM PAGE = 0
IoCode :> SRAM PAGE = 0
IoData :> L47SARAM PAGE = 0
DmaCode :> L47SARAM PAGE = 0
DmaData :> L47SARAM PAGE = 0
ServoCode :> L03SARAM PAGE = 0
ServoData :> L03SARAM PAGE = 0
Servo2Code :> L47SARAM PAGE = 0
Servo2Data :> L47SARAM PAGE = 0
DMARAML4 :> L47SARAM PAGE = 0
SramCode :> SRAM PAGE = 0
LexCode :> SRAM PAGE = 0

CanIsrCode :> L03SARAM PAGE = 0
pECanaMboxesData :> L03SARAM PAGE = 0

SramData :> SRAMDATA PAGE = 1
/* SaramCode :> MSARAM PAGE = 1 */
}

The 2024 Embedded Online Conference