From 0ad92fc56d5eb58e3427376df646f3e508637c75 Mon Sep 17 00:00:00 2001 From: Vreixo Formoso Date: Sat, 26 Jan 2008 15:39:58 +0100 Subject: [PATCH] struct iso_read_image_features is now allocated by libisofs. --- demo/iso_grow.c | 6 ++++-- src/fs_image.c | 17 +++++++++++------ src/libisofs.h | 19 ++++++++++--------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/demo/iso_grow.c b/demo/iso_grow.c index 9a2a048..4b0a07e 100644 --- a/demo/iso_grow.c +++ b/demo/iso_grow.c @@ -32,7 +32,7 @@ int main(int argc, char **argv) unsigned char buf[32 * 2048]; IsoWriteOpts *opts; int ret = 0; - struct iso_read_image_features features; + struct iso_read_image_features *features; uint32_t ms_block; IsoReadOpts *ropts; @@ -124,10 +124,12 @@ int main(int argc, char **argv) } /* round up to 32kb aligment = 16 block */ - ms_block = ((features.size + 15) / 16 ) * 16; + ms_block = ((features->size + 15) / 16 ) * 16; iso_write_opts_set_ms_block(opts, ms_block); iso_write_opts_set_appendable(opts, 1); iso_write_opts_set_overwrite_buf(opts, buf); + + free(features); result = iso_image_create_burn_source(image, opts, &burn_src); if (result < 0) { diff --git a/src/fs_image.c b/src/fs_image.c index 5a58103..1f585fb 100644 --- a/src/fs_image.c +++ b/src/fs_image.c @@ -2202,7 +2202,7 @@ boot_fs_cleanup: ; int iso_image_import(IsoImage *image, IsoDataSource *src, struct iso_read_opts *opts, - struct iso_read_image_features *features) + struct iso_read_image_features **features) { int ret; IsoImageFilesystem *fs; @@ -2346,11 +2346,16 @@ int iso_image_import(IsoImage *image, IsoDataSource *src, iso_image_set_biblio_file_id(image, data->biblio_file_id); if (features != NULL) { - features->hasJoliet = data->joliet; - features->hasRR = data->rr_version != 0; - features->hasIso1999 = data->iso1999; - features->hasElTorito = data->eltorito; - features->size = data->nblocks; + *features = malloc(sizeof(struct iso_read_image_features)); + if (*features == NULL) { + ret = ISO_OUT_OF_MEM; + goto import_cleanup; + } + (*features)->hasJoliet = data->joliet; + (*features)->hasRR = data->rr_version != 0; + (*features)->hasIso1999 = data->iso1999; + (*features)->hasElTorito = data->eltorito; + (*features)->size = data->nblocks; } ret = ISO_SUCCESS; diff --git a/src/libisofs.h b/src/libisofs.h index dfe7d01..b549d83 100644 --- a/src/libisofs.h +++ b/src/libisofs.h @@ -171,6 +171,12 @@ struct iso_data_source { */ struct iso_read_image_features { + /** + * Will be filled with the size (in 2048 byte block) of the image, as + * reported in the PVM. + */ + uint32_t size; + /** It will be set to 1 if RR extensions are present, to 0 if not. */ unsigned int hasRR :1; @@ -185,12 +191,6 @@ struct iso_read_image_features /** It will be set to 1 if El-Torito boot record is present, to 0 if not.*/ unsigned int hasElTorito :1; - - /** - * Will be filled with the size (in 2048 byte block) of the image, as - * reported in the PVM. - */ - uint32_t size; }; typedef struct iso_file_source IsoFileSource; @@ -946,14 +946,15 @@ int iso_read_opts_set_input_charset(IsoReadOpts *opts, const char *charset); * @param opts * Options for image import * @param features - * Will be filled with the features of the old image. You can pass NULL - * if you're not interested on them. + * If not NULL, a new struct iso_read_image_features will be allocated + * and filled with the features of the old image. It should be freed when + * no more needed. You can pass NULL if you're not interested on them. * @return * 1 on success, < 0 on error */ int iso_image_import(IsoImage *image, IsoDataSource *src, IsoReadOpts *opts, - struct iso_read_image_features *features); + struct iso_read_image_features **features); /** * Increments the reference counting of the given image.