зеркало из https://github.com/github/ruby.git
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:
Родитель
8dd9a23693
Коммит
c827cacde1
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче