From 5f1412ee6b1d2d5a0867dafc4a5d2d8075fa7922 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 28 Oct 2006 21:39:14 +0000 Subject: [PATCH] yasm_fopen_include: Allow oname to be NULL. Also set oname to NULL if NULL is returned. svn path=/trunk/yasm/; revision=1670 --- libyasm/file.c | 12 ++++++++++-- libyasm/file.h | 9 +++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/libyasm/file.c b/libyasm/file.c index 10f73fdf..f558695a 100644 --- a/libyasm/file.c +++ b/libyasm/file.c @@ -422,7 +422,10 @@ yasm_fopen_include(const char *iname, const char *from, const char *mode, combine = yasm__combpath(from, iname); f = fopen(combine, mode); if (f) { - *oname = combine; + if (oname) + *oname = combine; + else + yasm_xfree(combine); return f; } yasm_xfree(combine); @@ -432,12 +435,17 @@ yasm_fopen_include(const char *iname, const char *from, const char *mode, combine = yasm__combpath(np->path, iname); f = fopen(combine, mode); if (f) { - *oname = combine; + if (oname) + *oname = combine; + else + yasm_xfree(combine); return f; } yasm_xfree(combine); } + if (oname) + *oname = NULL; return NULL; } diff --git a/libyasm/file.h b/libyasm/file.h index f37062d0..d81061d2 100644 --- a/libyasm/file.h +++ b/libyasm/file.h @@ -182,12 +182,13 @@ char *yasm__combpath_win(const char *from, const char *to); * \param iname file to include * \param from file doing the including * \param mode fopen mode string - * \param oname full pathname of included file (may be relative) + * \param oname full pathname of included file (may be relative). NULL + * may be passed if this is unwanted. * \return fopen'ed include file, or NULL if not found. */ -/*@null@*/ FILE *yasm_fopen_include(const char *iname, const char *from, - const char *mode, - /*@out@*/ /*@only@*/ char **oname); +/*@null@*/ FILE *yasm_fopen_include + (const char *iname, const char *from, const char *mode, + /*@null@*/ /*@out@*/ /*@only@*/ char **oname); /** Delete any stored include paths added by yasm_add_include_path(). */