Allow objfmt initialize and cleanup function pointers to be NULL when not needed.

svn path=/trunk/yasm/; revision=663
0.3
Peter Johnson 23 years ago
parent 1f71e995ca
commit 45333b0225
  1. 3
      frontends/yasm/yasm.c
  2. 5
      libyasm/objfmt.h
  3. 3
      src/main.c
  4. 5
      src/objfmt.h

@ -234,6 +234,7 @@ main(int argc, char *argv[])
}
/* Initialize the object format */
if (cur_objfmt->initialize)
cur_objfmt->initialize(in_filename, obj_filename);
/* Set NASM as the parser */
@ -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();

@ -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

@ -234,6 +234,7 @@ main(int argc, char *argv[])
}
/* Initialize the object format */
if (cur_objfmt->initialize)
cur_objfmt->initialize(in_filename, obj_filename);
/* Set NASM as the parser */
@ -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();

@ -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

Loading…
Cancel
Save