malloc

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

malloc

2,201 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pierreJTL on Fri Apr 08 00:47:18 MST 2011
bonjour
I want to use malloc() but I don't know which .h file must be included.
I tried "malloc.h" , <malloc.h> ...
where I can found any information?
can you help me please.
merci
Pierre
0 Kudos
Reply
12 Replies

2,173 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pierreJTL on Fri Apr 08 07:14:58 MST 2011
it is ok now I set library on  nohost and it run.
thanks
 
Pierre
0 Kudos
Reply

2,173 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Fri Apr 08 06:42:32 MST 2011
This is in the Building FAQ at:
http://support.code-red-tech.com/CodeRedWiki/UndefinedReference
0 Kudos
Reply

2,173 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pierreJTL on Fri Apr 08 06:25:03 MST 2011
I'll be better in SOS as C code...
it is a link error
alloc.c:(.text.malloc+0x98): undefined reference to `_sbrk'
error.c:(.text._Csysdie+0x2c): undefined reference to `_Csyscall3'
stdlib.c:(.text.exit+0x30): undefined reference to `_Csyscall1'
and so on...
I forgot something
0 Kudos
Reply

2,173 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Fri Apr 08 05:51:49 MST 2011
Sorry, but I agree with TheFallGuy - you have not posted the error, and therefore we are unable to help. The best thing to do, is go to the (build) Console, select all of the contents, and copy and paste it into a forum post.
0 Kudos
Reply

2,173 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pierreJTL on Fri Apr 08 05:17:14 MST 2011
thanks for the link
I'll put it on my "marque page" to use it :)  ...
The error happens at compile and only  when I write malloc()
You can see the code and error message on previous messages
I start with  Lpcxpresso_3.6 and it is not easy to use it correctly the first time , do not be too severe
0 Kudos
Reply

2,173 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Fri Apr 08 03:58:27 MST 2011

Quote:

Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.

If you don't read the FAQ, you will keep coming back with more questions. It saves everybody time to read the FAQ.

BTW: I don't know the answer as there was no reasonable question. pierreJTL said " I have always an error" but no indication of what the error might by. My eyesight is quite good, but I can't see his screen from here.
0 Kudos
Reply

2,173 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by OXO on Fri Apr 08 03:46:14 MST 2011

Quote: TheFallGuy
Did you read the FAQ?
http://support.code-red-tech.com/CodeRedWiki/CodeRedFAQ

Especially the section on C Library



If you know the answer it's more helpful to give it [B][I][U]and[/U][/I][/B] recommend the faq docs.
0 Kudos
Reply

2,173 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Fri Apr 08 02:53:55 MST 2011
Did you read the FAQ?
http://support.code-red-tech.com/CodeRedWiki/CodeRedFAQ

Especially the section on C Library
0 Kudos
Reply

2,173 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pierreJTL on Fri Apr 08 02:52:20 MST 2011
I tried a new project whith only malloc() and I have always an error .
my code:
// TODO: insert other include files here
#include <stdlib.h>
// TODO: insert other definitions and declarations here
int main(void) {
    int *ptr ;
    // TODO: insert code here

    // Enter an infinite loop, just incrementing a counter
    volatile static int i = 0 ;

    ptr = (int*)malloc( 10 ) ;

    while(1) {
        i++ ;
    }
    return 0 ;
}
what's wrong?
0 Kudos
Reply

2,173 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pierreJTL on Fri Apr 08 02:21:52 MST 2011
I exclude a file from build and I want to re-include this file into the build.
how can I do?
merci
Pierre
0 Kudos
Reply

2,173 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pierreJTL on Fri Apr 08 02:16:42 MST 2011
thanks
but now I have an error when I write malloc():
Description    Resource    Path    Location    Type
make: *** [es1.axf] Error 1    es1        line 0    C/C++ Problem
can you help me again?
0 Kudos
Reply

2,173 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Fri Apr 08 01:02:49 MST 2011
Use:

#include <stdlib.h>
0 Kudos
Reply