From cb7bcd464425fb9e5d7896e2a36c3154aa8b6a80 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 2 Nov 2011 18:30:28 +0800 Subject: [PATCH] add support for (key, val) attribute list A (key, val) attribute list has this format { key1, val1, ..., keyN, valN, terminator } and the size is 2*N + 1 --- glsize.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/glsize.hpp b/glsize.hpp index 00356ae..a042a14 100644 --- a/glsize.hpp +++ b/glsize.hpp @@ -758,4 +758,24 @@ __AttribList_size(const T *pAttribList) } +/* + * (key, value) attribute list, terminated by the given terminator. + */ +template +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_ */ -- 2.7.4