提交 278b7205 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Decref and remove reference to self->base when allocating new memory

Thanks Fred for the review.
上级 1f8cb171
......@@ -396,8 +396,13 @@ int CudaNdarray_alloc_contiguous(CudaNdarray *self, const int nd, const inttype
{
return 0;
}
else
{
// The structure of self will be reused with newly allocated memory.
// If self was a view, we should remove the reference to its base.
// (If base was already NULL, the following has no effect.)
Py_XDECREF(self->base);
self->base = NULL;
// If self is a view, do not try to free its memory
if (self->data_allocated && device_free(self->devdata))
{
......@@ -421,7 +426,7 @@ int CudaNdarray_alloc_contiguous(CudaNdarray *self, const int nd, const inttype
self->devdata,
self);
self->data_allocated = size;
}
return 0;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论