@@ -85,6 +85,19 @@ static Stable_t *Stable_new (size_t capacity)
85
85
return (t );
86
86
}
87
87
88
+ static void Stable_free (Stable_t * table )
89
+ {
90
+ if (table != NULL ) {
91
+ for (i = 0 ; i < table -> t_size ; ++ i ) {
92
+ if (table -> t_recs [i ].c_size > 0 )
93
+ sm_free (table -> t_recs [i ].c_recs );
94
+ }
95
+
96
+ sm_free (table -> t_recs );
97
+ sm_free (table );
98
+ }
99
+ }
100
+
88
101
static int Stable_add (Stable_t * t , SEAP_cmdrec_t * r )
89
102
{
90
103
Stable_rec_t * t_r ;
@@ -138,10 +151,11 @@ int SEAP_cmdtbl_backendS_add (SEAP_cmdtbl_t *t, SEAP_cmdrec_t *r)
138
151
n = Stable_new (SEAP_CMDTBL_LARGE_TRESHOLD );
139
152
ret = SEAP_cmdtbl_backendL_apply (t , & Stable_conv , (void * )n );
140
153
141
- if (ret != 0 ) {
142
- SEAP_cmdtbl_backendS_free (t );
143
- return (ret );
144
- }
154
+ if (ret != 0 ) {
155
+ SEAP_cmdtbl_backendS_free (t );
156
+ Stable_free (n );
157
+ return ret ;
158
+ }
145
159
146
160
SEAP_cmdtbl_backendL_free (t );
147
161
t -> table = n ;
@@ -180,24 +194,17 @@ int SEAP_cmdtbl_backendS_cmp (SEAP_cmdrec_t *a, SEAP_cmdrec_t *b)
180
194
return (a -> code - b -> code );
181
195
}
182
196
183
- void SEAP_cmdtbl_backendS_free (SEAP_cmdtbl_t * t )
197
+ void SEAP_cmdtbl_backendS_free (SEAP_cmdtbl_t * t )
184
198
{
185
199
size_t i ;
186
200
Stable_t * St ;
187
-
201
+
188
202
St = (Stable_t * )(t -> table );
189
-
190
- if (St != NULL ) {
191
- for (i = 0 ; i < St -> t_size ; ++ i )
192
- if (St -> t_recs [i ].c_size > 0 )
193
- sm_free (St -> t_recs [i ].c_recs );
194
-
195
- sm_free (St -> t_recs );
196
- sm_free (St );
197
-
198
- t -> table = NULL ;
199
- }
200
- return ;
203
+
204
+ if (St != NULL ) {
205
+ Stable_free (St );
206
+ t -> table = NULL ;
207
+ }
201
208
}
202
209
203
210
int SEAP_cmdtbl_backendS_apply (SEAP_cmdtbl_t * t , int (* func ) (SEAP_cmdrec_t * r , void * ), void * arg )
0 commit comments