remove setCacheSize set cache in openDocument

pull/2/merge
Dobrica Pavlinusic 12 years ago
parent 2754d996c4
commit 5b1deedd86

@ -71,7 +71,7 @@ static int handle(lua_State *L, ddjvu_context_t *ctx, int wait)
static int openDocument(lua_State *L) {
const char *filename = luaL_checkstring(L, 1);
/*const char *password = luaL_checkstring(L, 2);*/
int cache_size = luaL_checkint(L, 2);
DjvuDocument *doc = (DjvuDocument*) lua_newuserdata(L, sizeof(DjvuDocument));
luaL_getmetatable(L, "djvudocument");
@ -82,6 +82,9 @@ static int openDocument(lua_State *L) {
return luaL_error(L, "cannot create context.");
}
printf("## cache_size = %d\n", cache_size);
ddjvu_cache_set_size(doc->context, cache_size);
doc->doc_ref = ddjvu_document_create_by_filename_utf8(doc->context, filename, TRUE);
while (! ddjvu_document_decoding_done(doc->doc_ref))
handle(L, doc->context, True);
@ -455,14 +458,6 @@ static int getCacheSize(lua_State *L) {
return 1;
}
static int setCacheSize(lua_State *L) {
DjvuDocument *doc = (DjvuDocument*) luaL_checkudata(L, 1, "djvudocument");
int size = luaL_checkint(L, 2);
printf("## ddjvu_cache_set_size = %d\n", size);
ddjvu_cache_set_size(doc->context, size);
return 0;
}
static int cleanCache(lua_State *L) {
DjvuDocument *doc = (DjvuDocument*) luaL_checkudata(L, 1, "djvudocument");
printf("## ddjvu_cache_clear\n");
@ -482,7 +477,6 @@ static const struct luaL_Reg djvudocument_meth[] = {
{"getPageText", getPageText},
{"close", closeDocument},
{"getCacheSize", getCacheSize},
{"setCacheSize", setCacheSize},
{"cleanCache", cleanCache},
{"__gc", closeDocument},
{NULL, NULL}

@ -6,7 +6,7 @@ DJVUReader = UniReader:new{}
-- DJVU does not support password yet
function DJVUReader:open(filename)
local ok
ok, self.doc = pcall(djvu.openDocument, filename)
ok, self.doc = pcall(djvu.openDocument, filename, self.cache_document_size)
if not ok then
return ok, self.doc -- this will be the error message instead
end

Loading…
Cancel
Save