]> git.cworth.org Git - apitrace/commitdiff
add support for (key, val) attribute list
authorChia-I Wu <olvaffe@gmail.com>
Wed, 2 Nov 2011 10:30:28 +0000 (18:30 +0800)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Tue, 8 Nov 2011 17:28:44 +0000 (17:28 +0000)
A (key, val) attribute list has this format

  { key1, val1, ..., keyN, valN, terminator }

and the size is 2*N + 1

glsize.hpp

index 00356ae7c64cb52383b654f38666fe0f6f0615b9..a042a140c97785cb97664388413ce103532bea15 100644 (file)
@@ -758,4 +758,24 @@ __AttribList_size(const T *pAttribList)
 }
 
 
+/*
+ * (key, value) attribute list, terminated by the given terminator.
+ */
+template<class T>
+static inline size_t
+__AttribList_size(const T *pAttribList, T terminator)
+{
+    size_t size = 0;
+
+    if (pAttribList) {
+        while (pAttribList[size] != terminator)
+            size += 2;
+        // terminator also counts
+        size++;
+    }
+
+    return size;
+}
+
+
 #endif /* _GL_SIZE_HPP_ */