Adafruit-GFX-Library icon indicating copy to clipboard operation
Adafruit-GFX-Library copied to clipboard

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

Open jlarnal opened this issue 4 years ago • 0 comments

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 ?

jlarnal avatar Oct 29 '21 22:10 jlarnal