ruby-changes:63250
From: Kenta <ko1@a...>
Date: Fri, 2 Oct 2020 08:04:40 +0900 (JST)
Subject: [ruby-changes:63250] c827cacde1 (master): memory_view.c: Use ssize_t for ndim in memory_view (#3615)
https://git.ruby-lang.org/ruby.git/commit/?id=c827cacde1 From c827cacde155c7b0a2d5e632c983cb38049f68e2 Mon Sep 17 00:00:00 2001 From: Kenta Murata <mrkn@u...> Date: Fri, 2 Oct 2020 08:04:25 +0900 Subject: memory_view.c: Use ssize_t for ndim in memory_view (#3615) * memory_view.c: Use ssize_t for ndim in memory_view * include/ruby/memory_view.h: Fix the type of item_size argument diff --git a/ext/-test-/memory_view/memory_view.c b/ext/-test-/memory_view/memory_view.c index 116f4ce..ba7cbd9 100644 --- a/ext/-test-/memory_view/memory_view.c +++ b/ext/-test-/memory_view/memory_view.c @@ -185,7 +185,7 @@ memory_view_get_memory_view_info(VALUE mod, VALUE obj) https://github.com/ruby/ruby/blob/trunk/ext/-test-/memory_view/memory_view.c#L185 static VALUE memory_view_fill_contiguous_strides(VALUE mod, VALUE ndim_v, VALUE item_size_v, VALUE shape_v, VALUE row_major_p) { - int i, ndim = FIX2INT(ndim_v); + ssize_t i, ndim = NUM2SSIZET(ndim_v); Check_Type(shape_v, T_ARRAY); ssize_t *shape = ALLOC_N(ssize_t, ndim); diff --git a/include/ruby/memory_view.h b/include/ruby/memory_view.h index 5d48c35..f9348f5 100644 --- a/include/ruby/memory_view.h +++ b/include/ruby/memory_view.h @@ -85,7 +85,7 @@ typedef struct { https://github.com/ruby/ruby/blob/trunk/include/ruby/memory_view.h#L85 } item_desc; /* The number of dimension. */ - int ndim; + ssize_t ndim; /* ndim size array indicating the number of elements in each dimension. * This can be NULL when ndim == 1. */ @@ -124,7 +124,7 @@ bool rb_memory_view_register(VALUE klass, const rb_memory_view_entry_t *entry); https://github.com/ruby/ruby/blob/trunk/include/ruby/memory_view.h#L124 int rb_memory_view_is_row_major_contiguous(const rb_memory_view_t *view); int rb_memory_view_is_column_major_contiguous(const rb_memory_view_t *view); -void rb_memory_view_fill_contiguous_strides(const int ndim, const int item_size, const ssize_t *const shape, const int row_major_p, ssize_t *const strides); +void rb_memory_view_fill_contiguous_strides(const ssize_t ndim, const ssize_t item_size, const ssize_t *const shape, const int row_major_p, ssize_t *const strides); int rb_memory_view_init_as_byte_array(rb_memory_view_t *view, VALUE obj, void *data, const ssize_t len, const int readonly); ssize_t rb_memory_view_parse_item_format(const char *format, rb_memory_view_item_component_t **members, diff --git a/memory_view.c b/memory_view.c index 6d75b9d..ea503c3 100644 --- a/memory_view.c +++ b/memory_view.c @@ -78,7 +78,7 @@ rb_memory_view_is_column_major_contiguous(const rb_memory_view_t *view) https://github.com/ruby/ruby/blob/trunk/memory_view.c#L78 /* Initialize strides array to represent the specified contiguous array. */ void -rb_memory_view_fill_contiguous_strides(const int ndim, const int item_size, const ssize_t *const shape, const int row_major_p, ssize_t *const strides) +rb_memory_view_fill_contiguous_strides(const ssize_t ndim, const ssize_t item_size, const ssize_t *const shape, const int row_major_p, ssize_t *const strides) { ssize_t i, n = item_size; if (row_major_p) { @@ -414,7 +414,7 @@ rb_memory_view_get_item_pointer(rb_memory_view_t *view, const ssize_t *indices) https://github.com/ruby/ruby/blob/trunk/memory_view.c#L414 assert(view->shape != NULL); - int i; + ssize_t i; if (view->strides == NULL) { // row-major contiguous array ssize_t stride = view->item_size; -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/