raku-community-modules / GD

Raku interface to the Gd graphics library.
Artistic License 2.0
2 stars 6 forks source link

gdPoint is a struct #9

Open jonathanstowe opened 4 years ago

jonathanstowe commented 4 years ago

The gdImagePolygon, gdImageOpenPolygon and gdImageFilledPolygon actually take a pointer to a flat array of:

typedef struct {
    int x, y;
}

The current implementation gets away with this because the array of structs will be layed out in memory as if it were an array of int32 with no word boundary padding on 32 or 64 bit platforms.

It would however be nicer if it were actually expressed as an array of structs if only to make the code clearer as to what is going on. There is some module in the ecosystem that can turn a CArray of pointers to structs into a flat array of the actual structs.