]> granicus.if.org Git - yasm/commitdiff
yasm_fopen_include: Allow oname to be NULL. Also set oname to NULL if NULL
authorPeter Johnson <peter@tortall.net>
Sat, 28 Oct 2006 21:39:14 +0000 (21:39 -0000)
committerPeter Johnson <peter@tortall.net>
Sat, 28 Oct 2006 21:39:14 +0000 (21:39 -0000)
is returned.

svn path=/trunk/yasm/; revision=1670

libyasm/file.c
libyasm/file.h

index 10f73fdfbaea19eb6542e6858ee8008153ef25e6..f558695af621c883febbbabd15a3affb0fb36adb 100644 (file)
@@ -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;
 }
 
index f37062d0ac60deae7882f2fba2f89bf4e868e09c..d81061d2b960b556fb10443ac55da1f6bc123aef 100644 (file)
@@ -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().
  */