Make qsort invocations type independent

This commit is contained in:
Kovid Goyal 2019-07-23 10:20:41 +05:30
parent 6a126fa18e
commit d9f90ef077
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 4 additions and 4 deletions

View File

@ -315,7 +315,7 @@ bool _glfwInitJoysticksLinux(void)
// Continue with no joysticks if enumeration fails
qsort(_glfw.joysticks, count, sizeof(_GLFWjoystick), compareJoysticks);
qsort(_glfw.joysticks, count, sizeof(_glfw.joysticks[0]), compareJoysticks);
return true;
}

2
glfw/monitor.c vendored
View File

@ -74,7 +74,7 @@ static bool refreshVideoModes(_GLFWmonitor* monitor)
if (!modes)
return false;
qsort(modes, modeCount, sizeof(GLFWvidmode), compareVideoModes);
qsort(modes, modeCount, sizeof(modes[0]), compareVideoModes);
free(monitor->modes);
monitor->modes = modes;

View File

@ -131,7 +131,7 @@ apply_storage_quota(GraphicsManager *self, size_t storage_limit, id_type current
remove_images(self, trim_predicate, currently_added_image_internal_id);
if (self->used_storage < storage_limit) return;
qsort(self->images, self->image_count, sizeof(Image), oldest_last);
qsort(self->images, self->image_count, sizeof(self->images[0]), oldest_last);
while (self->used_storage > storage_limit && self->image_count > 0) {
remove_image(self, self->image_count - 1);
}
@ -576,7 +576,7 @@ grman_update_layers(GraphicsManager *self, unsigned int scrolled_by, float scree
}}
if (!self->count) return false;
// Sort visible refs in draw order (z-index, img)
qsort(self->render_data, self->count, sizeof(ImageRenderData), cmp_by_zindex_and_image);
qsort(self->render_data, self->count, sizeof(self->render_data[0]), cmp_by_zindex_and_image);
// Calculate the group counts
i = 0;
while (i < self->count) {