55
66#define SP_POINT_SIZE (244)
77#define MAX_POINTS 2
8-
98#define SCRATCHBOARD_SIZE (640)
9+ #define TMP_BUFFER_SIZE (124)
10+ #define SP_DIGITS_SIZE (400)
11+ #define SP_NORMALIZER_SIZE (128)
12+
1013static uint8_t sp_scratchboard [SCRATCHBOARD_SIZE ];
1114static int sp_scratchboard_in_use = 0 ;
1215
1316static uint8_t sp_point_buffer0 [SP_POINT_SIZE ];
1417static uint8_t sp_point_buffer1 [SP_POINT_SIZE ];
18+ static uint8_t tmp_buffer [TMP_BUFFER_SIZE ];
19+ static uint8_t sp_three_points [SP_POINT_SIZE * 3 ];
20+ static uint8_t sp_digits [SP_DIGITS_SIZE ];
21+ static uint8_t sp_normalizer [SP_NORMALIZER_SIZE ];
1522
1623static int point_0_in_use = 0 ;
1724static int point_1_in_use = 0 ;
25+ static int tmp_buffer_in_use = 0 ;
26+ static int sp_three_points_in_use = 0 ;
27+ static int sp_digits_in_use = 0 ;
28+ static int sp_normalizer_in_use = 0 ;
1829
1930static void * xmalloc_sp_point (void )
2031{
@@ -36,12 +47,53 @@ static void* xmalloc_sp_scratchboard(void)
3647 return sp_scratchboard ;
3748}
3849
50+ static void * xmalloc_sp_tmpbuffer (void )
51+ {
52+ if (tmp_buffer_in_use )
53+ return NULL ;
54+ tmp_buffer_in_use ++ ;
55+ return tmp_buffer ;
56+ }
57+
58+ static void * xmalloc_sp_three_points (void )
59+ {
60+ if (sp_three_points_in_use )
61+ return NULL ;
62+ sp_three_points_in_use ++ ;
63+ return sp_three_points ;
64+ }
65+
66+ static void * xmalloc_sp_digits (void )
67+ {
68+ if (sp_digits_in_use )
69+ return NULL ;
70+ sp_digits_in_use ++ ;
71+ return sp_digits ;
72+ }
73+
74+ static void * xmalloc_sp_normalizer (void )
75+ {
76+ if (sp_normalizer_in_use )
77+ return NULL ;
78+ sp_normalizer_in_use ++ ;
79+ return sp_normalizer ;
80+ }
81+
82+
3983void * XMALLOC (size_t n , void * heap , int type )
4084{
4185 if (n == SP_POINT_SIZE )
4286 return xmalloc_sp_point ();
4387 if (n == SCRATCHBOARD_SIZE )
4488 return xmalloc_sp_scratchboard ();
89+ if (n == TMP_BUFFER_SIZE )
90+ return xmalloc_sp_tmpbuffer ();
91+ if (n == 3 * SP_POINT_SIZE )
92+ return xmalloc_sp_three_points ();
93+ if (n == SP_DIGITS_SIZE )
94+ return xmalloc_sp_digits ();
95+ if (n == SP_NORMALIZER_SIZE )
96+ return xmalloc_sp_normalizer ();
4597 return NULL ;
4698}
4799
@@ -53,4 +105,12 @@ void XFREE(void *ptr)
53105 point_1_in_use = 0 ;
54106 if (ptr == sp_scratchboard )
55107 sp_scratchboard_in_use = 0 ;
108+ if (ptr == tmp_buffer )
109+ tmp_buffer_in_use = 0 ;
110+ if (ptr == sp_three_points )
111+ sp_three_points_in_use = 0 ;
112+ if (ptr == sp_digits )
113+ sp_digits_in_use = 0 ;
114+ if (ptr == sp_normalizer )
115+ sp_normalizer_in_use = 0 ;
56116}
0 commit comments