/**
* 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(char **labelPtr, char *label, int *length, int bufSize)
+copy_label(const GLchar *src, GLchar *dst, GLsizei *length, GLsizei bufSize)
{
int labelLen = 0;
- if (*labelPtr)
- labelLen = strlen(*labelPtr);
+ /* From http://www.opengl.org/registry/specs/KHR/debug.txt:
+ * "If <length> is NULL, no length is returned. The maximum number of
+ * characters that may be written into <label>, including the null
+ * terminator, is specified by <bufSize>. If no debug label was specified
+ * for the object then <label> will contain a null-terminated empty string,
+ * and zero will be returned in <length>. If <label> is NULL and <length>
+ * is non-NULL then no string will be returned and the length of the label
+ * will be returned in <length>."
+ */
- if (label) {
- if (bufSize <= labelLen)
- labelLen = bufSize-1;
+ if (src)
+ labelLen = strlen(src);
+
+ if (dst) {
+ if (src) {
+ if (bufSize <= labelLen)
+ labelLen = bufSize - 1;
+
+ memcpy(dst, src, labelLen);
+ }
- memcpy(label, *labelPtr, labelLen);
- label[labelLen] = '\0';
+ dst[labelLen] = '\0';
}
if (length)
if (!labelPtr)
return;
- copy_label(labelPtr, label, length, bufSize);
+ copy_label(*labelPtr, label, length, bufSize);
}
void GLAPIENTRY
labelPtr = &syncObj->Label;
- copy_label(labelPtr, label, length, bufSize);
+ copy_label(*labelPtr, label, length, bufSize);
}