Per Hedbor () @ Pike (-) developers forum wrote:
Oh well. Needless to say, I have not actually tested the code. :-)
Thanks alot for the examples. I've actually already came to use something like Per recommended, since I don't need/use the stack to build the array. One question though, what defines the size of the array? Thought it was v->size. So, what's good/bad with my attempt this far (was about to test if it works or not, but you guys are too fast for me ;P)
THIS->acs_map = allocate_array( 512 ); add_ref( THIS->acs_map );
int i; for( i = 0; acs_map[i]; i++ ) { if( i > 512 ) // should grow, will fix later... Pike_error( "Unexpected large acs_map!" );
THIS->acs_map->item[ i ].u.integer = acs_map[ i ]; }
THIS->acs_map->size = i;
I'm aware of the allocate_array_no_init(0, 512) alternative, but the I would have to set the PIKE_T_INT type and stuff, right? so this feels a bit cleaner... but I'm not really sure about what I'm doing, just feels like it should work :ob