adafruit / Adafruit-GFX-Library

Adafruit GFX graphics core Arduino library, this is the 'core' class that all our other graphics libraries derive from
https://learn.adafruit.com/adafruit-gfx-graphics-library
Other
2.41k stars 1.55k forks source link

Adagruit_GFX::getTextBounds(...) should have their 'out ' arguments nullable, or passed as refs. #363

Open jlarnal opened 3 years ago

jlarnal commented 3 years ago

The current signature of Adafruit_GFX::getTextBounds are :

getTextBounds( [multiple_string_types] , int16_t , int16_t , int16_t, int16_t , uint16_t, uint16_t)

However, there is no non-null enforcement for the last 4 pointer arguments. Then one could believe (like I did), that passing NULL for unwanted out argument is an option. But it's not. 😅 ( dang, I just needed the height, nothing else) -wink-

If implementing the nullability of those args agrees to everyone's fancy, I'd be happy to do it. The function will stay backward-compatible doing this, and the caller won't have its stack hogged with 3 more ushorts.

Originally, wouldn't it be more reasonable to pass those as references ? What motivated the choice of pointers here ?