@@ -146,23 +146,24 @@ read_table_cols(kastore_t *store, tsk_size_t *num_rows, read_table_col_t *cols,
146
146
}
147
147
148
148
static int
149
- cast_offset_array (read_table_ragged_col_t * col , tsk_size_t num_rows )
149
+ cast_offset_array (read_table_ragged_col_t * col , uint64_t * source , tsk_size_t num_rows )
150
150
{
151
151
int ret = 0 ;
152
152
tsk_size_t len = num_rows + 1 ;
153
153
tsk_size_t j ;
154
- uint64_t * source = * col -> offset_array_dest ;
155
154
uint32_t * dest = malloc (len * sizeof (* dest ));
156
155
157
156
if (dest == NULL ) {
158
157
ret = TSK_ERR_NO_MEMORY ;
159
158
goto out ;
160
159
}
161
160
col -> offset_array_mem = dest ;
161
+ * col -> offset_array_dest = dest ;
162
162
for (j = 0 ; j < len ; j ++ ) {
163
- dest [j ] = source [j ]
163
+ /* We don't bother catching errors here because we'll be switching this
164
+ * to casting up to 64 bit soon; current version is temporary. */
165
+ dest [j ] = (uint32_t ) source [j ];
164
166
}
165
- col -> offset_col_present
166
167
out :
167
168
return ret ;
168
169
}
@@ -177,6 +178,7 @@ read_table_ragged_cols(kastore_t *store, tsk_size_t *num_rows,
177
178
read_table_ragged_col_t * col ;
178
179
char offset_col_name [TSK_MAX_COL_NAME_LEN ];
179
180
bool data_col_present , offset_col_present ;
181
+ void * store_offset_array ;
180
182
tsk_size_t * offset_array ;
181
183
182
184
for (col = cols ; col -> name != NULL ; col ++ ) {
@@ -220,8 +222,8 @@ read_table_ragged_cols(kastore_t *store, tsk_size_t *num_rows,
220
222
goto out ;
221
223
}
222
224
if (offset_col_present ) {
223
- ret = kastore_gets (store , offset_col_name , ( void * * ) col -> offset_array_dest ,
224
- & offset_len , & type );
225
+ ret = kastore_gets (
226
+ store , offset_col_name , & store_offset_array , & offset_len , & type );
225
227
if (ret != 0 ) {
226
228
ret = tsk_set_kas_error (ret );
227
229
goto out ;
@@ -241,12 +243,14 @@ read_table_ragged_cols(kastore_t *store, tsk_size_t *num_rows,
241
243
goto out ;
242
244
}
243
245
}
244
- if (type == KAS_UINT64 ) {
245
- ret = cast_offset_array (col , * num_rows );
246
+ if (type == KAS_UINT32 ) {
247
+ * col -> offset_array_dest = (uint32_t * ) store_offset_array ;
248
+ } else if (type == KAS_UINT64 ) {
249
+ ret = cast_offset_array (col , (uint64_t * ) store_offset_array , * num_rows );
246
250
if (ret != 0 ) {
247
251
goto out ;
248
252
}
249
- } else if ( type == KAS_UINT32 ) {
253
+ } else {
250
254
ret = TSK_ERR_BAD_COLUMN_TYPE ;
251
255
goto out ;
252
256
}
@@ -328,8 +332,22 @@ read_table(kastore_t *store, tsk_size_t *num_rows, read_table_col_t *cols,
328
332
return ret ;
329
333
}
330
334
335
+ static void
336
+ free_read_table_mem (read_table_col_t * TSK_UNUSED (cols ),
337
+ read_table_ragged_col_t * ragged_cols , read_table_property_t * TSK_UNUSED (properties ))
338
+ {
339
+ read_table_ragged_col_t * ragged_col ;
340
+
341
+ if (ragged_cols != NULL ) {
342
+ for (ragged_col = ragged_cols ; ragged_col -> name != NULL ; ragged_col ++ ) {
343
+ tsk_safe_free (ragged_col -> offset_array_mem );
344
+ }
345
+ }
346
+ }
347
+
331
348
static int
332
- write_offset_col (kastore_t * store , const write_table_ragged_col_t * col , tsk_flags_t options )
349
+ write_offset_col (
350
+ kastore_t * store , const write_table_ragged_col_t * col , tsk_flags_t options )
333
351
{
334
352
int ret = 0 ;
335
353
char offset_col_name [TSK_MAX_COL_NAME_LEN ];
@@ -350,7 +368,6 @@ write_offset_col(kastore_t *store, const write_table_ragged_col_t *col, tsk_flag
350
368
* to force huge arrays to test all the code paths.
351
369
*/
352
370
if (options & TSK_DUMP_FORCE_OFFSET_64 ) {
353
- printf ("write 64\n" );
354
371
offset64 = malloc (len * sizeof (* offset64 ));
355
372
if (offset64 == NULL ) {
356
373
ret = TSK_ERR_NO_MEMORY ;
@@ -376,8 +393,8 @@ write_offset_col(kastore_t *store, const write_table_ragged_col_t *col, tsk_flag
376
393
}
377
394
378
395
static int
379
- write_table_ragged_cols (kastore_t * store , const write_table_ragged_col_t * write_cols ,
380
- tsk_flags_t options )
396
+ write_table_ragged_cols (
397
+ kastore_t * store , const write_table_ragged_col_t * write_cols , tsk_flags_t options )
381
398
{
382
399
int ret = 0 ;
383
400
const write_table_ragged_col_t * col ;
@@ -1234,7 +1251,8 @@ tsk_individual_table_equals(const tsk_individual_table_t *self,
1234
1251
}
1235
1252
1236
1253
static int
1237
- tsk_individual_table_dump (const tsk_individual_table_t * self , kastore_t * store , tsk_flags_t options )
1254
+ tsk_individual_table_dump (
1255
+ const tsk_individual_table_t * self , kastore_t * store , tsk_flags_t options )
1238
1256
{
1239
1257
const write_table_col_t write_cols [] = {
1240
1258
{ "individuals/flags" , (void * ) self -> flags , self -> num_rows ,
@@ -1277,11 +1295,11 @@ tsk_individual_table_load(tsk_individual_table_t *self, kastore_t *store)
1277
1295
};
1278
1296
read_table_ragged_col_t ragged_cols [] = {
1279
1297
{ "individuals/location" , (void * * ) & location , & location_length , KAS_FLOAT64 ,
1280
- & location_offset , 0 , NULL },
1298
+ & location_offset , 0 , NULL },
1281
1299
{ "individuals/parents" , (void * * ) & parents , & parents_length ,
1282
- TSK_ID_STORAGE_TYPE , & parents_offset , TSK_COL_OPTIONAL , NULL },
1300
+ TSK_ID_STORAGE_TYPE , & parents_offset , TSK_COL_OPTIONAL , NULL },
1283
1301
{ "individuals/metadata" , (void * * ) & metadata , & metadata_length , KAS_UINT8 ,
1284
- & metadata_offset , 0 , NULL },
1302
+ & metadata_offset , 0 , NULL },
1285
1303
{ .name = NULL },
1286
1304
};
1287
1305
read_table_property_t properties [] = {
@@ -1307,6 +1325,7 @@ tsk_individual_table_load(tsk_individual_table_t *self, kastore_t *store)
1307
1325
}
1308
1326
}
1309
1327
out :
1328
+ free_read_table_mem (cols , ragged_cols , properties );
1310
1329
return ret ;
1311
1330
}
1312
1331
@@ -1873,7 +1892,7 @@ tsk_node_table_load(tsk_node_table_t *self, kastore_t *store)
1873
1892
};
1874
1893
read_table_ragged_col_t ragged_cols [] = {
1875
1894
{ "nodes/metadata" , (void * * ) & metadata , & metadata_length , KAS_UINT8 ,
1876
- & metadata_offset , 0 , NULL },
1895
+ & metadata_offset , 0 , NULL },
1877
1896
{ .name = NULL },
1878
1897
};
1879
1898
read_table_property_t properties [] = {
@@ -1899,6 +1918,7 @@ tsk_node_table_load(tsk_node_table_t *self, kastore_t *store)
1899
1918
}
1900
1919
}
1901
1920
out :
1921
+ free_read_table_mem (cols , ragged_cols , properties );
1902
1922
return ret ;
1903
1923
}
1904
1924
@@ -2509,7 +2529,7 @@ tsk_edge_table_load(tsk_edge_table_t *self, kastore_t *store)
2509
2529
};
2510
2530
read_table_ragged_col_t ragged_cols [] = {
2511
2531
{ "edges/metadata" , (void * * ) & metadata , & metadata_length , KAS_UINT8 ,
2512
- & metadata_offset , TSK_COL_OPTIONAL , NULL },
2532
+ & metadata_offset , TSK_COL_OPTIONAL , NULL },
2513
2533
{ .name = NULL },
2514
2534
};
2515
2535
read_table_property_t properties [] = {
@@ -2535,6 +2555,7 @@ tsk_edge_table_load(tsk_edge_table_t *self, kastore_t *store)
2535
2555
}
2536
2556
}
2537
2557
out :
2558
+ free_read_table_mem (cols , ragged_cols , properties );
2538
2559
return ret ;
2539
2560
}
2540
2561
@@ -3180,9 +3201,9 @@ tsk_site_table_load(tsk_site_table_t *self, kastore_t *store)
3180
3201
};
3181
3202
read_table_ragged_col_t ragged_cols [] = {
3182
3203
{ "sites/ancestral_state" , (void * * ) & ancestral_state , & ancestral_state_length ,
3183
- KAS_UINT8 , & ancestral_state_offset , 0 , NULL },
3204
+ KAS_UINT8 , & ancestral_state_offset , 0 , NULL },
3184
3205
{ "sites/metadata" , (void * * ) & metadata , & metadata_length , KAS_UINT8 ,
3185
- & metadata_offset , 0 , NULL },
3206
+ & metadata_offset , 0 , NULL },
3186
3207
{ .name = NULL },
3187
3208
};
3188
3209
read_table_property_t properties [] = {
@@ -3208,6 +3229,7 @@ tsk_site_table_load(tsk_site_table_t *self, kastore_t *store)
3208
3229
}
3209
3230
}
3210
3231
out :
3232
+ free_read_table_mem (cols , ragged_cols , properties );
3211
3233
return ret ;
3212
3234
}
3213
3235
@@ -3817,7 +3839,8 @@ tsk_mutation_table_dump_text(const tsk_mutation_table_t *self, FILE *out)
3817
3839
}
3818
3840
3819
3841
static int
3820
- tsk_mutation_table_dump (const tsk_mutation_table_t * self , kastore_t * store , tsk_flags_t options )
3842
+ tsk_mutation_table_dump (
3843
+ const tsk_mutation_table_t * self , kastore_t * store , tsk_flags_t options )
3821
3844
{
3822
3845
const write_table_col_t cols [] = {
3823
3846
{ "mutations/site" , (void * ) self -> site , self -> num_rows , TSK_ID_STORAGE_TYPE },
@@ -3865,9 +3888,9 @@ tsk_mutation_table_load(tsk_mutation_table_t *self, kastore_t *store)
3865
3888
};
3866
3889
read_table_ragged_col_t ragged_cols [] = {
3867
3890
{ "mutations/derived_state" , (void * * ) & derived_state , & derived_state_length ,
3868
- KAS_UINT8 , & derived_state_offset , 0 , NULL },
3891
+ KAS_UINT8 , & derived_state_offset , 0 , NULL },
3869
3892
{ "mutations/metadata" , (void * * ) & metadata , & metadata_length , KAS_UINT8 ,
3870
- & metadata_offset , 0 , NULL },
3893
+ & metadata_offset , 0 , NULL },
3871
3894
{ .name = NULL },
3872
3895
};
3873
3896
read_table_property_t properties [] = {
@@ -3893,6 +3916,7 @@ tsk_mutation_table_load(tsk_mutation_table_t *self, kastore_t *store)
3893
3916
}
3894
3917
}
3895
3918
out :
3919
+ free_read_table_mem (cols , ragged_cols , properties );
3896
3920
return ret ;
3897
3921
}
3898
3922
@@ -4413,7 +4437,8 @@ tsk_migration_table_equals(const tsk_migration_table_t *self,
4413
4437
}
4414
4438
4415
4439
static int
4416
- tsk_migration_table_dump (const tsk_migration_table_t * self , kastore_t * store , tsk_flags_t options )
4440
+ tsk_migration_table_dump (
4441
+ const tsk_migration_table_t * self , kastore_t * store , tsk_flags_t options )
4417
4442
{
4418
4443
const write_table_col_t cols [] = {
4419
4444
{ "migrations/left" , (void * ) self -> left , self -> num_rows , KAS_FLOAT64 },
@@ -4462,7 +4487,7 @@ tsk_migration_table_load(tsk_migration_table_t *self, kastore_t *store)
4462
4487
};
4463
4488
read_table_ragged_col_t ragged_cols [] = {
4464
4489
{ "migrations/metadata" , (void * * ) & metadata , & metadata_length , KAS_UINT8 ,
4465
- & metadata_offset , TSK_COL_OPTIONAL , NULL },
4490
+ & metadata_offset , TSK_COL_OPTIONAL , NULL },
4466
4491
{ .name = NULL },
4467
4492
};
4468
4493
read_table_property_t properties [] = {
@@ -4488,6 +4513,7 @@ tsk_migration_table_load(tsk_migration_table_t *self, kastore_t *store)
4488
4513
}
4489
4514
}
4490
4515
out :
4516
+ free_read_table_mem (cols , ragged_cols , properties );
4491
4517
return ret ;
4492
4518
}
4493
4519
@@ -4942,7 +4968,8 @@ tsk_population_table_equals(const tsk_population_table_t *self,
4942
4968
}
4943
4969
4944
4970
static int
4945
- tsk_population_table_dump (const tsk_population_table_t * self , kastore_t * store , tsk_flags_t options )
4971
+ tsk_population_table_dump (
4972
+ const tsk_population_table_t * self , kastore_t * store , tsk_flags_t options )
4946
4973
{
4947
4974
const write_table_col_t cols [] = {
4948
4975
{ "populations/metadata_schema" , (void * ) self -> metadata_schema ,
@@ -4969,7 +4996,7 @@ tsk_population_table_load(tsk_population_table_t *self, kastore_t *store)
4969
4996
4970
4997
read_table_ragged_col_t ragged_cols [] = {
4971
4998
{ "populations/metadata" , (void * * ) & metadata , & metadata_length , KAS_UINT8 ,
4972
- & metadata_offset , 0 , NULL },
4999
+ & metadata_offset , 0 , NULL },
4973
5000
{ .name = NULL },
4974
5001
};
4975
5002
read_table_property_t properties [] = {
@@ -4994,6 +5021,7 @@ tsk_population_table_load(tsk_population_table_t *self, kastore_t *store)
4994
5021
}
4995
5022
}
4996
5023
out :
5024
+ free_read_table_mem (NULL , ragged_cols , properties );
4997
5025
return ret ;
4998
5026
}
4999
5027
@@ -5510,7 +5538,8 @@ tsk_provenance_table_equals(const tsk_provenance_table_t *self,
5510
5538
}
5511
5539
5512
5540
static int
5513
- tsk_provenance_table_dump (const tsk_provenance_table_t * self , kastore_t * store , tsk_flags_t options )
5541
+ tsk_provenance_table_dump (
5542
+ const tsk_provenance_table_t * self , kastore_t * store , tsk_flags_t options )
5514
5543
{
5515
5544
write_table_ragged_col_t ragged_cols [] = {
5516
5545
{ "provenances/timestamp" , (void * ) self -> timestamp , self -> timestamp_length ,
@@ -5535,9 +5564,9 @@ tsk_provenance_table_load(tsk_provenance_table_t *self, kastore_t *store)
5535
5564
5536
5565
read_table_ragged_col_t ragged_cols [] = {
5537
5566
{ "provenances/timestamp" , (void * * ) & timestamp , & timestamp_length , KAS_UINT8 ,
5538
- & timestamp_offset , 0 , NULL },
5567
+ & timestamp_offset , 0 , NULL },
5539
5568
{ "provenances/record" , (void * * ) & record , & record_length , KAS_UINT8 ,
5540
- & record_offset , 0 , NULL },
5569
+ & record_offset , 0 , NULL },
5541
5570
{ .name = NULL },
5542
5571
};
5543
5572
@@ -5551,6 +5580,7 @@ tsk_provenance_table_load(tsk_provenance_table_t *self, kastore_t *store)
5551
5580
goto out ;
5552
5581
}
5553
5582
out :
5583
+ free_read_table_mem (NULL , ragged_cols , NULL );
5554
5584
return ret ;
5555
5585
}
5556
5586
@@ -9949,7 +9979,8 @@ tsk_table_collection_read_format_data(tsk_table_collection_t *self, kastore_t *s
9949
9979
}
9950
9980
9951
9981
static int TSK_WARN_UNUSED
9952
- tsk_table_collection_dump_indexes (const tsk_table_collection_t * self , kastore_t * store , tsk_flags_t TSK_UNUSED (options ))
9982
+ tsk_table_collection_dump_indexes (const tsk_table_collection_t * self , kastore_t * store ,
9983
+ tsk_flags_t TSK_UNUSED (options ))
9953
9984
{
9954
9985
int ret = 0 ;
9955
9986
write_table_col_t cols [] = {
@@ -10136,8 +10167,8 @@ tsk_table_collection_load(
10136
10167
}
10137
10168
10138
10169
static int TSK_WARN_UNUSED
10139
- tsk_table_collection_write_format_data (
10140
- const tsk_table_collection_t * self , kastore_t * store , tsk_flags_t TSK_UNUSED (options ))
10170
+ tsk_table_collection_write_format_data (const tsk_table_collection_t * self ,
10171
+ kastore_t * store , tsk_flags_t TSK_UNUSED (options ))
10141
10172
{
10142
10173
int ret = 0 ;
10143
10174
char format_name [TSK_FILE_FORMAT_NAME_LENGTH ];
@@ -10199,7 +10230,8 @@ tsk_table_collection_dump(
10199
10230
}
10200
10231
10201
10232
int TSK_WARN_UNUSED
10202
- tsk_table_collection_dumpf (const tsk_table_collection_t * self , FILE * file , tsk_flags_t options )
10233
+ tsk_table_collection_dumpf (
10234
+ const tsk_table_collection_t * self , FILE * file , tsk_flags_t options )
10203
10235
{
10204
10236
int ret = 0 ;
10205
10237
kastore_t store ;
0 commit comments