[Mesa-dev] [PATCH V2 10/15] mesa: Implement KHR_debug ObjectLabel functions
Fredrik Höglund
fredrik at kde.org
Tue Aug 27 15:25:40 PDT 2013
On Tuesday 27 August 2013, Timothy Arceri wrote:
> V2: fixed indentation of comment
>
> Signed-off-by: Timothy Arceri <t_arceri at yahoo.com.au>
> ---
> src/mesa/main/objectlabel.c | 277 ++++++++++++++++++++++++++++++++++++++++++++
> src/mesa/main/objectlabel.h | 61 ++++++++++
> 2 files changed, 338 insertions(+)
> create mode 100644 src/mesa/main/objectlabel.c
> create mode 100644 src/mesa/main/objectlabel.h
>
> diff --git a/src/mesa/main/objectlabel.c b/src/mesa/main/objectlabel.c
> new file mode 100644
> index 0000000..78f9b33
> --- /dev/null
> +++ b/src/mesa/main/objectlabel.c
> @@ -0,0 +1,277 @@
> +/*
> + * 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 "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)
> +{
> + if (*labelPtr) {
> + /* free old label string */
> + free(*labelPtr);
You should set *labelPtr to NULL here, since the code below is not guaranteed
to assign it.
> + }
> +
> + if (label) {
> + /* set new label string */
> +
> + if (length >= 0) {
> + /* explicit length */
> + *labelPtr = (char *) malloc(length);
> + if (*labelPtr) {
> + memcpy(*labelPtr, label, length);
> + }
The length given by the client is not required to include a terminating
null-character.
> + }
> + else {
> + /* null-terminated string */
> + int len = strlen(label);
> + if (len >= MAX_LABEL_LENGTH) {
> + /* An INVALID_VALUE error is generated if the number of characters
> + * in <label>, excluding the null terminator when <length> is
> + * negative, is not less than the value of 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);
This error should also be generated when the client specifies an explicit
length that exceeds MAX_LABEL_LENGTH.
Fredrik
More information about the mesa-dev
mailing list