Nicht eingeloggt.
Passwort vergessen?


Bitte erst registrieren. Danach ist es möglich Beiträge zu schreiben.



 Nach unten   Vorheriges Thema   Nächstes Thema

#1
malloc
Geschrieben am: 31.10.2009 20:43
VUE(xpert)
Dabei seit 03.09.2003
Schweden
442 Beiträge
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
Nach oben

#2
Re: malloc
Geschrieben am: 01.11.2009 19:05
PVB Elite
Dabei seit 25.07.2003
USA
1507 Beiträge
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
Nach oben

#3
Re: malloc
Geschrieben am: 01.11.2009 22:18
VUE(xpert)
Dabei seit 03.09.2003
Schweden
442 Beiträge
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...
Nach oben

#4
Re: malloc
Geschrieben am: 01.11.2009 22:20
PVB Elite
Dabei seit 25.07.2003
USA
1507 Beiträge
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
Nach oben

#5
Re: malloc
Geschrieben am: 01.11.2009 23:26
VUE(xpert)
Dabei seit 27.10.2007
Schweden
418 Beiträge
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?
Nach oben

#6
Re: malloc
Geschrieben am: 11.11.2009 16:59
Nintendoid!
Dabei seit 15.03.2006
Ecuador
239 Beiträge
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
Nach oben

 Nach oben   Vorheriges Thema   Nächstes Thema


Bitte erst registrieren. Danach ist es möglich Beiträge zu schreiben.