1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-22 04:50:09 +00:00

slightly better memory management

This commit is contained in:
Lu Wang 2012-09-07 07:55:10 +08:00
parent 1a27eeddff
commit 82dd71c803
3 changed files with 29 additions and 0 deletions

View File

@ -44,6 +44,7 @@ HTMLRenderer::HTMLRenderer(const Param * param)
HTMLRenderer::~HTMLRenderer()
{
ff_fin();
clean_tmp_files();
delete [] cur_mapping;
delete [] cur_mapping2;

View File

@ -21,6 +21,7 @@
static FontViewBase * cur_fv = NULL;
static Encoding * original_enc = NULL;
static Encoding * enc_head = NULL;
static void err(const char * format, ...)
{
@ -65,6 +66,26 @@ void ff_init(void)
original_enc = FindOrMakeEncoding("original");
}
void ff_fin(void)
{
while(enc_head)
{
Encoding * next = enc_head->next;
free(enc_head->enc_name);
free(enc_head->unicode);
if(enc_head->psnames)
{
int i;
for(i = 0; i < enc_head->char_cnt; ++i)
free(enc_head->psnames[i]);
free(enc_head->psnames);
}
free(enc_head);
enc_head = next;
}
}
void ff_load_font(const char * filename)
{
char * _filename = strcopy(filename);
@ -125,6 +146,9 @@ void ff_reencode_raw(int32 * mapping, int mapping_len, int force)
memcpy(enc->unicode, mapping, mapping_len * sizeof(int32_t));
enc->enc_name = strcopy("");
enc->next = enc_head;
enc_head = enc;
ff_do_reencode(enc, force);
}
@ -149,6 +173,9 @@ void ff_reencode_raw2(char ** mapping, int mapping_len, int force)
}
}
enc->next = enc_head;
enc_head = enc;
ff_do_reencode(enc, force);
}

View File

@ -19,6 +19,7 @@ extern "C" {
#endif
void ff_init(void);
void ff_fin(void);
void ff_load_font(const char * filename);
void ff_reencode_glyph_order(void);
void ff_reencode_raw(int32_t * mapping, int mapping_len, int force);