Sha256: d42a6627f0488a9f5f131e6e20115d62c44b384d3f22f7129f4811251f012a61

Contents?: true

Size: 859 Bytes

Versions: 7

Compression:

Stored size: 859 Bytes

Contents

static VALUE
<%=c_func%>(VALUE self)
{
    narray_t *na;
    char *ptr;

    GetNArray(self,na);

    switch(NA_TYPE(na)) {
    case NARRAY_DATA_T:
        ptr = NA_DATA_PTR(na);
        if (na->size > 0 && ptr == NULL) {
            ptr = xmalloc(sizeof(dtype) * na->size);
            <% if is_object %>
            {   size_t i;
                VALUE *a = (VALUE*)ptr;
                for (i=na->size; i--;) {
                    *a++ = Qnil;
                }
            }
            <% end %>
            NA_DATA_PTR(na) = ptr;
        }
        break;
    case NARRAY_VIEW_T:
        rb_funcall(NA_VIEW_DATA(na), rb_intern("allocate"), 0);
        break;
    case NARRAY_FILEMAP_T:
        //ptr = ((narray_filemap_t*)na)->ptr;
        // to be implemented
    default:
        rb_bug("invalid narray type : %d",NA_TYPE(na));
    }
    return self;
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
numo-narray-0.9.0.4 ext/numo/narray/gen/tmpl/allocate.c
numo-narray-0.9.0.3-x86-mingw32 ext/numo/narray/gen/tmpl/allocate.c
numo-narray-0.9.0.3-x64-mingw32 ext/numo/narray/gen/tmpl/allocate.c
numo-narray-0.9.0.3 ext/numo/narray/gen/tmpl/allocate.c
numo-narray-0.9.0.1-x64-mingw32 ext/numo/narray/gen/tmpl/allocate.c
numo-narray-0.9.0.1 ext/numo/narray/gen/tmpl/allocate.c
numo-narray-0.9.0.1-x86-mingw32 ext/numo/narray/gen/tmpl/allocate.c