[waffle] [PATCH 02/11] core: Define intptr_t variants of wcore_attrib_list functions

Chad Versace chad.versace at intel.com
Wed Dec 31 17:11:47 PST 2014


On 12/23/2014 04:23 PM, Frank Henigman wrote:
> On Tue, Dec 16, 2014 at 3:18 AM, Chad Versace
> <chad.versace at linux.intel.com> wrote:
>> When designing the original Waffle 1.0 API, I made a mistake when
>> I chose to declare attribute lists as arrays of int32_t. Instead, they
>> should have been arrays of intptr_t.
>>
>> A new public function, waffle_window_create2, will have a `const
>> intptr_t attrib_list[]` parameter. Therefore waffle needs intptr_t
>> variants of the wcore_attrib_list functions.
>>
>> Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
>> ---
>>  src/waffle/core/wcore_attrib_list.c | 73 +++++++++++++++++++++++++++++++++++++
>>  src/waffle/core/wcore_attrib_list.h | 23 ++++++++++++
>>  2 files changed, 96 insertions(+)
>>



>> +bool
>> +wcore_attrib_list_update(
>> +        intptr_t *attrib_list,
>> +        intptr_t key,
>> +        intptr_t value)
>> +{
>> +    intptr_t *i = attrib_list;
>> +
>> +    if (attrib_list == NULL)
>> +        return false;
>> +
>> +    while (*i != 0 && *i != key)
>> +        i += 2;
>> +
>> +    if (*i == key) {
>> +        i[1] = value;
>> +        return true;
>> +    }
>> +    else {
>> +        return false;
>> +    }
>> +}
> 
> Speaking of wincing (patch 00/11 thread) this code duplication makes
> me wince.  If we really have to keep outside facing int32_t functions,
> can we immediately translate int32_t's passed into them to intptr_t's
> and keep waffle internals all intptr_t?  With an eye to deprecating
> the int32_t interfaces?

Yes. This duplication made me wince too.

In v2 of the series, I'll remove the duplication by immediately translating
int32_t lists to intptr_t lists. I'll also follow-up with some deprecation
mechanism for the public waffle_attrib_list functions.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 884 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/waffle/attachments/20141231/7d3ea71b/attachment.sig>


More information about the waffle mailing list