[GRASS5] How to get monitor background color?
cworth at east.isi.edu
Fri, 26 Oct 2001 09:48:15 -0400
Markus Neteler writes:
> However, it doesn't work for me (I may be lost again with strings
> and pointers):
> char * colorname;
> int bgcolor;
Markus, the code above is broken. You're passing an uninitialized
pointer (colorname), to D_get_erase_Color. Inside, that function does:
which is sure to segfault or worse if colorname is not pointing to
Instead, you should first ensure that colorname is pointing to some
allocated memory large enough to hold the resulting color. Something
I have no idea what value might be appropriate for MAX_COLOR_LEN.
(And if there isn't a well-defined value for this somewhere, then
D_get_erase_color should be updated to accept a maximum length as an
input parameter or to allocate memory for the result itself).