summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/omegafonts
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2014-09-22 09:02:46 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2014-09-22 09:02:46 +0000
commita24bf8c59f33a1f347db0fd2270862a2a59a1954 (patch)
tree39977b15918d385d0800c6ff8599d763949f0545 /Build/source/texk/web2c/omegafonts
parent07c19404819d7af7ff27110ca79bf51761fbd2f0 (diff)
texk/web2c/omegafonts: Memory managment bug fix and cleanup
git-svn-id: svn://tug.org/texlive/trunk@35229 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/omegafonts')
-rw-r--r--Build/source/texk/web2c/omegafonts/ChangeLog6
-rw-r--r--Build/source/texk/web2c/omegafonts/font_routines.c23
2 files changed, 19 insertions, 10 deletions
diff --git a/Build/source/texk/web2c/omegafonts/ChangeLog b/Build/source/texk/web2c/omegafonts/ChangeLog
index a4deb9b61cf..826f6886191 100644
--- a/Build/source/texk/web2c/omegafonts/ChangeLog
+++ b/Build/source/texk/web2c/omegafonts/ChangeLog
@@ -1,3 +1,9 @@
+2014-09-22 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * font_routines.c: Fixed packet_table realloc bug.
+ Clean up font_table and move_table memory management.
+ Reduce BLOCK 256 => 16 to reduce wasted packet_table space.
+
2014-08-20 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
* char_routines.c: Move '#define check_range' to the top-level.
diff --git a/Build/source/texk/web2c/omegafonts/font_routines.c b/Build/source/texk/web2c/omegafonts/font_routines.c
index 578af168d07..79944cef735 100644
--- a/Build/source/texk/web2c/omegafonts/font_routines.c
+++ b/Build/source/texk/web2c/omegafonts/font_routines.c
@@ -34,7 +34,7 @@ along with Omega; if not, write to the Free Software Foundation, Inc.,
#include "out_routines.h"
#include "omfonts.h"
-#define BLOCK 256
+#define BLOCK 16
font *font_table = NULL;
unsigned font_table_size = 0;
@@ -49,17 +49,19 @@ unsigned vf_design_size = 0;
void
font_table_init(void)
{
- font_table_size = BLOCK;
- font_table = (font *) xmalloc(font_table_size);
+ if (font_table == NULL) {
+ font_table_size = BLOCK;
+ font_table = (font *) xmalloc(font_table_size * sizeof(font));
+ }
no_fonts = 0;
}
static void
font_no_incr(void)
{
- if (no_fonts * BLOCK == font_table_size) {
+ if (no_fonts == font_table_size) {
font_table_size += BLOCK;
- font_table = (font *) xrealloc(font_table, font_table_size);
+ font_table = (font *) xrealloc(font_table, font_table_size * sizeof(font));
}
no_fonts++;
}
@@ -205,7 +207,7 @@ unsigned char *packet_table = NULL;
unsigned char *cur_packet = NULL;
unsigned packet_ptr = 0;
-void
+static void
packet_table_init(void)
{
packet_table_size = BLOCK;
@@ -221,6 +223,7 @@ packet_ptr_incr(void)
packet_table_size += BLOCK;
packet_table = (unsigned char *)
xrealloc(packet_table, packet_table_size);
+ cur_packet = packet_table;
}
packet_ptr++;
}
@@ -403,14 +406,14 @@ move_table_init(void)
{
if (move_table == NULL) {
move_table_size = BLOCK;
- move_table = (move *) xmalloc(move_table_size);
+ move_table = (move *) xmalloc(move_table_size * sizeof(move));
}
move_ptr = 0;
cur_move = move_table;
cur_move->h = 0; cur_move->v = 0;
}
-void
+static void
packet_table_end(void)
{
cur_packet = NULL;
@@ -431,11 +434,11 @@ move_ptr_decr(void)
static void
move_ptr_incr(void)
{
+ move_ptr++;
if (move_ptr == move_table_size) {
move_table_size += BLOCK;
- move_table = (move *) xrealloc(move_table, move_table_size);
+ move_table = (move *) xrealloc(move_table, move_table_size * sizeof(move));
}
- move_ptr++;
cur_move = &move_table[move_ptr];
}