1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
Kenta Murata 2020-10-02 08:04:25 +09:00 committed by GitHub
parent 8dd9a23693
commit c827cacde1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2020-10-02 08:04:50 +09:00
Merged-By: mrkn <mrkn@ruby-lang.org>
3 changed files with 5 additions and 5 deletions

View file

@ -185,7 +185,7 @@ memory_view_get_memory_view_info(VALUE mod, VALUE obj)
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);

View file

@ -85,7 +85,7 @@ typedef struct {
} 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);
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,

View file

@ -78,7 +78,7 @@ rb_memory_view_is_column_major_contiguous(const rb_memory_view_t *view)
/* 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)
assert(view->shape != NULL);
int i;
ssize_t i;
if (view->strides == NULL) {
// row-major contiguous array
ssize_t stride = view->item_size;