Commit 6520bbd2 authored by Chad Versace's avatar Chad Versace

core: Change return type of wcore_attrib_list32_length

Change from int32_t to size_t, because
    - Length is a measurement of unsigned "size".
    - In general, length values are often used in subsequent calculation
      of memory size which is passed to functions like malloc, whose
      input is size_t not int.
    - The cast from ptrdiff_t to int32_t in wcore_attrib_list_length
      just looked wrong. A cast to size_t makes more sense.

As precedent, strlen() also returns size_t.
Signed-off-by: default avatarChad Versace <chad.versace@intel.com>
Tested-by: Emil Velikov <emil.l.velikov@gmail.com> (msvc/wgl)
Reviewed-by: Emil Velikov's avatarEmil Velikov <emil.l.velikov@gmail.com>
parent dbaa77e6
......@@ -29,7 +29,7 @@
#include <stdint.h>
#include <stddef.h>
int32_t
size_t
wcore_attrib_list32_length(const int32_t attrib_list[])
{
const int32_t *i = attrib_list;
......@@ -40,7 +40,7 @@ wcore_attrib_list32_length(const int32_t attrib_list[])
while (*i != 0)
i += 2;
return (int32_t) (i - attrib_list) / 2;
return (i - attrib_list) / 2;
}
bool
......
......@@ -26,9 +26,10 @@
#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
int32_t
size_t
wcore_attrib_list32_length(const int32_t attrib_list[]);
bool
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment