Skip to content
Permalink
Browse files Browse the repository at this point in the history
[lite] Update TfLiteIntArrayCreate to return size_t
PiperOrigin-RevId: 416439896
Change-Id: I847f69b68d1ddaff4b1e925a09b8b69c1756653b
  • Loading branch information
karimnosseir authored and tensorflower-gardener committed Dec 15, 2021
1 parent 4f1a8c1 commit a1e1511
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions tensorflow/lite/c/common.c
Expand Up @@ -21,10 +21,10 @@ limitations under the License.
#include <string.h>
#endif // TF_LITE_STATIC_MEMORY

int TfLiteIntArrayGetSizeInBytes(int size) {
size_t TfLiteIntArrayGetSizeInBytes(int size) {
static TfLiteIntArray dummy;

int computed_size = sizeof(dummy) + sizeof(dummy.data[0]) * size;
size_t computed_size = sizeof(dummy) + sizeof(dummy.data[0]) * size;
#if defined(_MSC_VER)
// Context for why this is needed is in http://b/189926408#comment21
computed_size -= sizeof(dummy.data[0]);
Expand All @@ -51,7 +51,7 @@ int TfLiteIntArrayEqualsArray(const TfLiteIntArray* a, int b_size,
#ifndef TF_LITE_STATIC_MEMORY

TfLiteIntArray* TfLiteIntArrayCreate(int size) {
int alloc_size = TfLiteIntArrayGetSizeInBytes(size);
size_t alloc_size = TfLiteIntArrayGetSizeInBytes(size);
if (alloc_size <= 0) return NULL;
TfLiteIntArray* ret = (TfLiteIntArray*)malloc(alloc_size);
if (!ret) return ret;
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/c/common.h
Expand Up @@ -98,7 +98,7 @@ typedef struct TfLiteIntArray {

// Given the size (number of elements) in a TfLiteIntArray, calculate its size
// in bytes.
int TfLiteIntArrayGetSizeInBytes(int size);
size_t TfLiteIntArrayGetSizeInBytes(int size);

#ifndef TF_LITE_STATIC_MEMORY
// Create a array of a given `size` (uninitialized entries).
Expand Down

0 comments on commit a1e1511

Please sign in to comment.