[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Public WebGL] TypedArray constructors and zero length
A zero-length array still has a .buffer property, which has to be non-null -- thus it has to be of zero size if the array was created with 'new Int32Array(0);'. The behaviour of malloc(0) isn't really relevant, though, as the underlying implementation can just have its raw data pointer be NULL without ever calling malloc; ArrayBuffer itself still needs additional metadata inside an implementation, so it can't ever just be a bare chunk of memory.
- Vlad
----- "Cedric Vivier" <cedricv@neonux.com> wrote:
> Hey Vlad,
>
>
> On Thu, Jun 10, 2010 at 01:42, Vladimir Vukicevic <
> vladimir@mozilla.com > wrote:
>
>
>
>
>
> 0 is a valid length; you should be able to create 0-length arrays as
> necessary, otherwise there's no way to represent a valid empty array.
> You'd have to pass null, which means special casing everything that
> works with arrays to understand null.
>
>
> Zero-length arrays might make sense but zero-length buffers ? I see
> ArrayBuffer as a way to efficiently allocate packed (buffer) memory
> from Javascript, hence my question about such behavior (ie. malloc(0)
> or equivalent on some GCs will fail).
>
>
> Not sure to get what you imply by "special casing everything that
> works with arrays" ?
> TypedArray are interface types so null is already a potential 'legal'
> value to take care of afaik.
>
>
> In my understanding supporting 0-length arrays requires additional
> special casing on top of that, for avoiding divide by zero and
> internal memory housekeeping.
>
>
>
>
> And as the length is already unsigned, then it can't ever be negative,
> so I don't think we need to do any special language here.
>
>
>
> I see, so what should happen in this case ? TYPE_ERR ?
>
>
>
>
> Regards,
-----------------------------------------------------------
You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email: