pd->graphics->fillPolygon rewrites input array when points are duplicated

Hi there -- I'm having a great time getting to grips with the Playdate C API by porting an open-source set of puzzles over to the platform (which I've worked with before).

Because the main code is very cross-platform, the small screen size sometimes means it gets asked to draw some very tiny things. I've found what originally looked like a rendering bug in the code, which when I looked into it seems to be an unexpected behaviour in the API: when you pass the pd->graphics->fillPolygon an array of points which contains duplicate (x,y) pairs, it actually edits the array you pass in so as to un-duplicate things. This would be fine, except that my function wants to fill the polygon and then outline it (in what is possibly a different colour), and when it comes to loop over the points to outline, the fact that the array was changed means that the sets of (x1,y1) -> (x2,y2) points can include some that shouldn't have been drawn.

Here's an example, from my debugging:

polygon (8 points), fill -823441728, outline -823441728
 - #0: (69,26)
 - #1: (69,26)
 - #2: (69,26)
 - #3: (46,26)
 - #4: (46,26)
 - #5: (69,26)
 - #6: (69,49)
 - #7: (69,49)
 - #0 (after): (69,26)
 - #1 (after): (46,26)
 - #2 (after): (69,26)
 - #3 (after): (69,49)
 - #4 (after): (46,26)
 - #5 (after): (69,26)
 - #6 (after): (69,49)
 - #7 (after): (69,49)
 - o0: (69,26) -> (46,26)
 - o1: (46,26) -> (69,26)
 - o2: (69,26) -> (69,49)
 - o3: ***(69,49) -> (46,26)***
 - o4: (46,26) -> (69,26)
 - o5: (69,26) -> (69,49)
 - o6: (69,49) -> (69,49)
 - o7: (69,49) -> (69,26)

This shows the point array going in, and the point array after the fillPolygon call, and the set of lines it then uses to outline. The highlighted pair should not have been drawn, but because the input set got shuffled around, it was.

Is this intentional behaviour within the API? In general, one of the things that isn't always clear about the C API is who owns the parameters passed into the API functions, and this is one of those cases: it's not at all clear from the API docs that the caller should expect the array they passed into get mutated under some circumstances.

I can work around it (by copying the array away before I use the fillPolygon function), but I thought the behaviour was unexpected so I wanted to check here in case it was unintentional.