summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Versace <chad.versace@intel.com>2015-01-04 13:36:04 -0800
committerChad Versace <chad.versace@intel.com>2015-01-27 09:36:05 -0800
commit6520bbd2aebc17a42855d169d0e896de0de46148 (patch)
treef0ce8e7f3bf2ec11cb5ec92fd672a39563311ba2
parentdbaa77e60eae2acc58a8b40e24bdd2bd4af071bb (diff)
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: Chad Versace <chad.versace@intel.com> Tested-by: Emil Velikov <emil.l.velikov@gmail.com> (msvc/wgl) Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
-rw-r--r--src/waffle/core/wcore_attrib_list.c4
-rw-r--r--src/waffle/core/wcore_attrib_list.h3
2 files changed, 4 insertions, 3 deletions
diff --git a/src/waffle/core/wcore_attrib_list.c b/src/waffle/core/wcore_attrib_list.c
index 09a4dec..b80f5cf 100644
--- a/src/waffle/core/wcore_attrib_list.c
+++ b/src/waffle/core/wcore_attrib_list.c
@@ -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
diff --git a/src/waffle/core/wcore_attrib_list.h b/src/waffle/core/wcore_attrib_list.h
index 8339578..15bd8ba 100644
--- a/src/waffle/core/wcore_attrib_list.h
+++ b/src/waffle/core/wcore_attrib_list.h
@@ -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