X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fglx%2Fglxconfig.c;h=569d24bfac56b6de0f8ca366c3c2e2167545cad9;hb=997040e4b8353fe9b71a5e9fde2f933eae09c7a3;hp=c3e1d5a568044067816f2d662ec74ac8951f20c8;hpb=6538b5824e298eaebede2d9686c7607c44ab446a;p=mesa.git diff --git a/src/glx/glxconfig.c b/src/glx/glxconfig.c index c3e1d5a5680..569d24bfac5 100644 --- a/src/glx/glxconfig.c +++ b/src/glx/glxconfig.c @@ -32,7 +32,6 @@ */ #include -#include "GL/glxint.h" #include #include @@ -60,7 +59,7 @@ glx_config_get(struct glx_config * mode, int attribute, int *value_return) *value_return = mode->rgbBits; return 0; case GLX_RGBA: - *value_return = mode->rgbMode; + *value_return = !(mode->renderType & GLX_COLOR_INDEX_BIT); return 0; case GLX_RED_SIZE: *value_return = mode->redBits; @@ -213,65 +212,49 @@ glx_config_get(struct glx_config * mode, int attribute, int *value_return) * values from the extension specification. * * \param count Number of structures to allocate. - * \param minimum_size Minimum size of a structure to allocate. This allows - * for differences in the version of the - * \c struct glx_config stucture used in libGL and in a - * DRI-based driver. * \returns A pointer to the first element in a linked list of \c count * stuctures on success, or \c NULL on failure. */ _X_HIDDEN struct glx_config * glx_config_create_list(unsigned count) { - const size_t size = sizeof(struct glx_config); - struct glx_config *base = NULL; - struct glx_config **next; + struct glx_config *c = NULL; unsigned i; - next = &base; - for (i = 0; i < count; i++) { - *next = (struct glx_config *) malloc(size); - if (*next == NULL) { - glx_config_destroy_list(base); - base = NULL; - break; - } + if (!(c = calloc(count, sizeof(struct glx_config)))) + return NULL; - (void) memset(*next, 0, size); - (*next)->visualID = GLX_DONT_CARE; - (*next)->visualType = GLX_DONT_CARE; - (*next)->visualRating = GLX_NONE; - (*next)->transparentPixel = GLX_NONE; - (*next)->transparentRed = GLX_DONT_CARE; - (*next)->transparentGreen = GLX_DONT_CARE; - (*next)->transparentBlue = GLX_DONT_CARE; - (*next)->transparentAlpha = GLX_DONT_CARE; - (*next)->transparentIndex = GLX_DONT_CARE; - (*next)->xRenderable = GLX_DONT_CARE; - (*next)->fbconfigID = GLX_DONT_CARE; - (*next)->swapMethod = GLX_SWAP_UNDEFINED_OML; - (*next)->bindToTextureRgb = GLX_DONT_CARE; - (*next)->bindToTextureRgba = GLX_DONT_CARE; - (*next)->bindToMipmapTexture = GLX_DONT_CARE; - (*next)->bindToTextureTargets = GLX_DONT_CARE; - (*next)->yInverted = GLX_DONT_CARE; - (*next)->sRGBCapable = GLX_DONT_CARE; + for (i = 0; i < count; i++) { + c[i].visualID = GLX_DONT_CARE; + c[i].visualType = GLX_DONT_CARE; + c[i].visualRating = GLX_NONE; + c[i].transparentPixel = GLX_NONE; + c[i].transparentRed = GLX_DONT_CARE; + c[i].transparentGreen = GLX_DONT_CARE; + c[i].transparentBlue = GLX_DONT_CARE; + c[i].transparentAlpha = GLX_DONT_CARE; + c[i].transparentIndex = GLX_DONT_CARE; + c[i].xRenderable = GLX_DONT_CARE; + c[i].fbconfigID = GLX_DONT_CARE; + c[i].swapMethod = GLX_SWAP_UNDEFINED_OML; + c[i].bindToTextureRgb = GLX_DONT_CARE; + c[i].bindToTextureRgba = GLX_DONT_CARE; + c[i].bindToMipmapTexture = GLX_DONT_CARE; + c[i].bindToTextureTargets = GLX_DONT_CARE; + c[i].yInverted = GLX_DONT_CARE; + c[i].sRGBCapable = GLX_DONT_CARE; - next = &((*next)->next); + if (i != count -1) + c[i].next = &(c[i+1]); } - return base; + return c; } _X_HIDDEN void glx_config_destroy_list(struct glx_config *configs) { - while (configs != NULL) { - struct glx_config *const next = configs->next; - - free(configs); - configs = next; - } + free(configs); }