Re: [AD] mode-list updates. |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Tuesday 02 October 2001 02:50, Peter Wang wrote:
> Btw, in both modesel.c and bgfxapi.cpp, `realloc' is being used
> incorrectly.
Oh really? i think you are mistaken here, unless you can convince me
otherwise.
realloc has some cool features. for example if ptr is NULL it works
equivalent to malloc and if size is 0 it works equivalent to free.
ps! i saw in the beos fetch mode list that both malloc and realloc was used,
it's cooler to just set a pointer to NULL and do realloc each time a gfx mode
is added. that's how directx fetch_mode_list() works.
AFAIK on processors where paging is enabled. realloc first tries re-allocate
memory by using the rest of the 4K page, since mode lists usually are less in
size no 'movement' of data is needed. I think most OSes are smart enough to
allocate data in whole pages and when realloc needs another page the OS just
alters the page tables instead of physically moving the data. so it is fast,
faster and simpler than linked lists. correct me if i'm wrong!
--
Sincerely Henrik Stokseth.
-----------------------------------------------------------------------
E-mail: hstokset@xxxxxxxxxx Homepage: http://hstokset.n3.net