From 45333b0225f65d3d5503b7c9f4f5150c6b0ffae3 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 8 Aug 2002 00:59:42 +0000 Subject: [PATCH] Allow objfmt initialize and cleanup function pointers to be NULL when not needed. svn path=/trunk/yasm/; revision=663 --- frontends/yasm/yasm.c | 5 +++-- libyasm/objfmt.h | 5 ++++- src/main.c | 5 +++-- src/objfmt.h | 5 ++++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c index 8a7c4c1b..4a8b9600 100644 --- a/frontends/yasm/yasm.c +++ b/frontends/yasm/yasm.c @@ -234,7 +234,8 @@ main(int argc, char *argv[]) } /* Initialize the object format */ - cur_objfmt->initialize(in_filename, obj_filename); + if (cur_objfmt->initialize) + cur_objfmt->initialize(in_filename, obj_filename); /* Set NASM as the parser */ cur_parser = find_parser("nasm"); @@ -338,7 +339,7 @@ cleanup(sectionhead *sections) { sections_delete(sections); symrec_delete_all(); - if (cur_objfmt) + if (cur_objfmt && cur_objfmt->cleanup) cur_objfmt->cleanup(); line_shutdown(); diff --git a/libyasm/objfmt.h b/libyasm/objfmt.h index 24d96fd7..527b3a8f 100644 --- a/libyasm/objfmt.h +++ b/libyasm/objfmt.h @@ -54,6 +54,7 @@ struct objfmt { /* Initializes object output. Must be called before any other object * format functions. Should NOT open the object file; the filenames are * provided solely for informational purposes. + * May be NULL if not needed by the object format. */ void (*initialize) (const char *in_filename, const char *obj_filename); @@ -63,7 +64,9 @@ struct objfmt { */ void (*output) (FILE *f, sectionhead *sections); - /* Cleans up anything allocated by initialize. */ + /* Cleans up anything allocated by initialize. + * May be NULL if not needed by the object format. + */ void (*cleanup) (void); /* Switch object file sections. The first val of the valparams should diff --git a/src/main.c b/src/main.c index 8a7c4c1b..4a8b9600 100644 --- a/src/main.c +++ b/src/main.c @@ -234,7 +234,8 @@ main(int argc, char *argv[]) } /* Initialize the object format */ - cur_objfmt->initialize(in_filename, obj_filename); + if (cur_objfmt->initialize) + cur_objfmt->initialize(in_filename, obj_filename); /* Set NASM as the parser */ cur_parser = find_parser("nasm"); @@ -338,7 +339,7 @@ cleanup(sectionhead *sections) { sections_delete(sections); symrec_delete_all(); - if (cur_objfmt) + if (cur_objfmt && cur_objfmt->cleanup) cur_objfmt->cleanup(); line_shutdown(); diff --git a/src/objfmt.h b/src/objfmt.h index 24d96fd7..527b3a8f 100644 --- a/src/objfmt.h +++ b/src/objfmt.h @@ -54,6 +54,7 @@ struct objfmt { /* Initializes object output. Must be called before any other object * format functions. Should NOT open the object file; the filenames are * provided solely for informational purposes. + * May be NULL if not needed by the object format. */ void (*initialize) (const char *in_filename, const char *obj_filename); @@ -63,7 +64,9 @@ struct objfmt { */ void (*output) (FILE *f, sectionhead *sections); - /* Cleans up anything allocated by initialize. */ + /* Cleans up anything allocated by initialize. + * May be NULL if not needed by the object format. + */ void (*cleanup) (void); /* Switch object file sections. The first val of the valparams should