Re: Ver 4.0 allocate() question

new topic     » goto parent     » topic index » view thread      » older message » newer message
DerekParnell said...
SDPringle said...

most of the time when you allocate memory you are about to poke something interesting into it anyway

That is a good point. So maybe the default action should be to not clear the allocation and if you want it cleared, then use the extra parameter.

atom m1, m2 
m1 = allocate(80)          -- Eighty bytes of uncleared RAM allocated. 
m2 = allocate(80, CLEARED) -- Eighty bytes of cleared RAM allocated. 

Or perhaps leave allocate as is and add

function allocate_set(integer size,object filler=0,integer filler_size=1) 
-- allocates ##size## bytes of memory, and fills the block with ##filler##. 
-- ##filler## is a value that will be stored as a ##filler_size##-byte bvalue with little endian encoding. 
-- ##filler## is chopped off to fit into ##filler_size## bytes, and the copy of ##filler# at the highest address may be truncated if ##size## is not a multiple of ##size_filler##. 
-- If ##filler## is a sequence, then it will be repeatedly poked in memory, ##filler_soze## being ignored and set to be the length of the sequence. This can be handy for filling up with floating point nnumbers. 

Do we need an extra option for big endian encodings?

CChris

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu