Skip to content

Commit

Permalink
Checking that allocator is NULL when creating a storage as a view.
Browse files Browse the repository at this point in the history
  • Loading branch information
zakattacktwitter committed May 26, 2015
1 parent 86d25ef commit e75f09c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion generic/Storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit e75f09c

Please sign in to comment.