Sha256: 90c716fd336be60b331cf9319e85a5e007ad6759771cb7d4f3a2332eb944e59a

Contents?: true

Size: 900 Bytes

Versions: 6

Compression:

Stored size: 900 Bytes

Contents

static VALUE
<%=c_func(0)%>(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;
            NA_DATA_OWNED(na) = TRUE;
        }
        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

6 entries across 6 versions & 1 rubygems

Version Path
numo-narray-0.9.2.1 ext/numo/narray/gen/tmpl/allocate.c
numo-narray-0.9.2.0 ext/numo/narray/gen/tmpl/allocate.c
numo-narray-0.9.1.9 ext/numo/narray/gen/tmpl/allocate.c
numo-narray-0.9.1.8 ext/numo/narray/gen/tmpl/allocate.c
numo-narray-0.9.1.7 ext/numo/narray/gen/tmpl/allocate.c
numo-narray-0.9.1.6 ext/numo/narray/gen/tmpl/allocate.c