From e75f09c7a9be6d18e3d443d33a5e312e7efe1685 Mon Sep 17 00:00:00 2001 From: ztaylor Date: Tue, 26 May 2015 08:48:03 -0700 Subject: [PATCH] Checking that allocator is NULL when creating a storage as a view. --- generic/Storage.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/generic/Storage.c b/generic/Storage.c index 8ddc1983..61c4c2fa 100644 --- a/generic/Storage.c +++ b/generic/Storage.c @@ -41,6 +41,9 @@ static int torch_Storage_(new)(lua_State *L) } else if(lua_type(L, index) == LUA_TUSERDATA) { + if (allocator) + THError("Passing allocator not supported when using storage views"); + THStorage *src = luaT_checkudata(L, index, torch_Storage); if (src->flag & TH_STORAGE_VIEW) { // don't allow chained views @@ -231,7 +234,7 @@ static int torch_Storage_(write)(lua_State *L) { THStorage *storage = luaT_checkudata(L, 1, torch_Storage); THFile *file = luaT_checkudata(L, 2, "torch.File"); - + THFile_writeLongScalar(file, storage->size); THFile_writeRealRaw(file, storage->data, storage->size);