You are not logged in.
Lost Password?


Register To Post



 Bottom   Previous Topic   Next Topic

#1
malloc
Posted on: 2009/10/31 19:43

Joined 2003/9/3
Sweden
-1 Posts
PVBCC EntryHighscore Top10 3rdCoderContributorHOTY09 2ndLong Time User (15 Years) DonatorApp CoderPVBCC 2010 1st20+ Game RatingsPVBCC 2013 2nd
Did anyone get malloc/free working with gccVB? I got inspired to get back to some vb dev again but I get these compiler errors:

/usr/local/v810/bin/ldwarningno memory region specified for section `.sdata'

/usr/local/v810/lib/libc.a(malloc.o): In function 
`malloc':
/home/Dan/vb_v810_gcc_03/newlib_build/v810/newlib/libc/stdlib/../../../../../new
lib-1.10.0/newlib/libc/stdlib/malloc.c:194: could not locate special linker symb
ol __gp
/usr/local/v810/lib/libc.a(malloc.o): In function `free'
:
/
home/Dan/vb_v810_gcc_03/newlib_build/v810/newlib/libc/stdlib/../../../../../new
lib-1.10.0/newlib/libc/stdlib/malloc.c:201could not locate special linker symb
ol __gp
/usr/local/v810/lib/libc.a(sbrkr.o): In function `sbrk_r':
/home/Dan/vb_v810_gcc_03/newlib_build/v810/newlib/libc/reent/../../../../../newl
ib-1.10.0/newlib/libc/reent/sbrkr.c:60: undefined reference to 
`sbrk'
/home/Dan/vb_v810_gcc_03/newlib_build/v810/newlib/libc/reent/../../../../../newl
ib-1.10.0/newlib/libc/reent/sbrkr.c:60: relocation truncated to fit: R_V810_26_P
CREL sbrk
/usr/local/v810/lib/libc.a(reent.o): In function `reclaim_reent'
:
/
home/Dan/vb_v810_gcc_03/newlib_build/v810/newlib/libc/reent/../../../../../newl
ib
-1.10.0/newlib/libc/reent/reent.c:48could not locate special linker symbol _
_gp
/usr/local/v810/lib/libc.a(reent.o): In function `wrapup_reent':
/home/Dan/vb_v810_gcc_03/newlib_build/v810/newlib/libc/reent/../../../../../newl
ib-1.10.0/newlib/libc/reent/reent.c:114: could not locate special linker symbol
__gp
collect2: ld returned 1 exit status
make: *** [all] Error 1
Top

#2
Re: malloc
Posted on: 2009/11/1 18:05

Joined 2003/7/25
USA
-1 Posts
PVBCC 1stCoderContributor#3 PosterHOTY09 EntryLong Time User (15 Years) App CoderPVBCC 2010 EntryPVBCC 2013 Entry
Hey Dan... nice to see you around again. I've never tried to use malloc on the VB, because I don't think it's supposed to work. Probably with a little work you could do it, but with the small amount of memory, I'm not sure you'd want to. I assume it doesn't work because we have no heap space. But if you start allocating and deallocating memory on the heap, it can get fragmented quickly and waste a lot of space.

I'm no expert on this subject, but David Tucker could probably give you a lot of insight into it, and maybe give you ideas how to fix it if you wanted to.

What's the need for dynamic allocation though? Can't you just declare arrays/variables statically and just reuse them (you could even just declare a big chunk and make pointers for the various uses, as long as you keep track of which ones you can use at which times)?

DogP
Top

#3
Re: malloc
Posted on: 2009/11/1 21:18

Joined 2003/9/3
Sweden
-1 Posts
PVBCC EntryHighscore Top10 3rdCoderContributorHOTY09 2ndLong Time User (15 Years) DonatorApp CoderPVBCC 2010 1st20+ Game RatingsPVBCC 2013 2nd
I just thought it would be practical for a linked list with the enemies and items in zelda, but I already have it working the way I need it to using static arrays instead, so no biggie...
Top

#4
Re: malloc
Posted on: 2009/11/1 21:20

Joined 2003/7/25
USA
-1 Posts
PVBCC 1stCoderContributor#3 PosterHOTY09 EntryLong Time User (15 Years) App CoderPVBCC 2010 EntryPVBCC 2013 Entry
Ah... yep... when I was working on Mario, I created a linked list kinda thing w/ static arrays as well.

DogP
Top

#5
Re: malloc
Posted on: 2009/11/1 22:26

Joined 2007/10/27
Sweden
-1 Posts
ContributorLong Time User (12 Years) 40+ Game Ratings
DanB: so u are working on Zelda vb game? or maybe ur starteing on Virtual Wario Ware again?
Top

#6
Re: malloc
Posted on: 2009/11/11 15:59

Joined 2006/3/15
Ecuador
-1 Posts
PVBCC 3rdCoderLong Time User (14 Years)
Hi guys, DanB I have a generic solution for this kind of stuff in my engine, you just need to grab the following classes:

MemoryPool: which does exactly the same as DogP says, that is to allocate static arrays of memory, but it's generic so you can just ask it to allocate/deallocate space for your data no matter what kind of.

VirtualList: it's a generic list like that in stl (with some limitations) and uses void* pointers to hold any kind of data.

I wrote to David T. a while ago asking about malloc/free and he told me that to activate it in the compiler it would be mandatory to reserve 32KB from the 64KB of work RAM for the heap, so it's completely impractical.

BTW, I have newer versions of those classes which I have not released yet, if any one is interested in them just PM me :-).

jorgeche
Top

 Top   Previous Topic   Next Topic


Register To Post