On Tue May 7 08:37:34 2024 +0000, Zhiyi Zhang wrote:
static void add_xrandr14_mode( DEVMODEW *mode, XRRModeInfo *info, DWORD depth, DWORD frequency, DWORD orientation ) DWORD orientation, BOOL full ) { mode->dmSize = sizeof(*mode); mode->dmDriverExtra = sizeof(RRMode); mode->dmDriverExtra = full ? sizeof(RRMode) : 0;
/* Allocate space for display modes in different color depths and orientations. * Store a RRMode at the end of each DEVMODEW as private driver data */ modes = calloc( output_info->nmode * DEPTH_COUNT * orientation_count, sizeof(*modes) + sizeof(RRMode) );
The problem is that dmDriverExtra is 0 when full is FALSE, yet the memory for dmDriverExtra is still allocated, which means you can't use NEXT_DEVMODEW to iterate such a DEVMODEW array.
It's just a contiguous array you can very well write the elements the way you like as long as there's enough memory?