/* * Mesa 3-D graphics library * * Copyright (C) 2013 Timothy Arceri All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ #include "arrayobj.h" #include "bufferobj.h" #include "context.h" #include "dlist.h" #include "enums.h" #include "fbobject.h" #include "objectlabel.h" #include "pipelineobj.h" #include "queryobj.h" #include "samplerobj.h" #include "shaderobj.h" #include "syncobj.h" #include "texobj.h" #include "transformfeedback.h" /** * Helper for _mesa_ObjectLabel() and _mesa_ObjectPtrLabel(). */ static void set_label(struct gl_context *ctx, char **labelPtr, const char *label, int length, const char *caller) { free(*labelPtr); *labelPtr = NULL; /* set new label string */ if (label) { if (length >= 0) { if (length >= MAX_LABEL_LENGTH) _mesa_error(ctx, GL_INVALID_VALUE, "%s(length=%d, which is not less than " "GL_MAX_LABEL_LENGTH=%d)", caller, length, MAX_LABEL_LENGTH); /* explicit length */ *labelPtr = malloc(length+1); if (*labelPtr) { memcpy(*labelPtr, label, length); /* length is not required to include the null terminator so * add one just in case */ (*labelPtr)[length] = '\0'; } } else { int len = strlen(label); if (len >= MAX_LABEL_LENGTH) _mesa_error(ctx, GL_INVALID_VALUE, "%s(label length=%d, which is not less than " "GL_MAX_LABEL_LENGTH=%d)", caller, len, MAX_LABEL_LENGTH); /* null-terminated string */ *labelPtr = strdup(label); } } } /** * Helper for _mesa_GetObjectLabel() and _mesa_GetObjectPtrLabel(). * \param src the src label (may be null) * \param dst pointer to dest buffer (may be null) * \param length returns length of label (may be null) * \param bufsize size of dst buffer */ static void copy_label(const GLchar *src, GLchar *dst, GLsizei *length, GLsizei bufSize) { int labelLen = 0; /* From http://www.opengl.org/registry/specs/KHR/debug.txt: * "If is NULL, no length is returned. The maximum number of * characters that may be written into