[aurelien@aurel32.net: [PATCH] confuse: correctly free all memory]

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[aurelien@aurel32.net: [PATCH] confuse: correctly free all memory]

Martin Hedenfalk-4
Aurelien, I took the liberty of forwarding your patch to the mailing list for
wider testing.

I'm looking for confirmation that this doesn't break anything.

        .martin

----- Forwarded message from Aurelien Jarno <[hidden email]> -----

Date: Sat, 24 May 2014 16:41:02 +0200
From: Aurelien Jarno <[hidden email]>
To: [hidden email]
Cc: Aurelien Jarno <[hidden email]>
Subject: [PATCH] confuse: correctly free all memory
X-Mailer: git-send-email 2.0.0.rc0

When calling cfg_free(), we also have to free the memory allocated by
the lexer to avoid memory leak.

Signed-off-by: Aurelien Jarno <[hidden email]>
---
 src/confuse.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/confuse.c b/src/confuse.c
index 5e0dcee..b01a01a 100644
--- a/src/confuse.c
+++ b/src/confuse.c
@@ -50,6 +50,7 @@
 
 extern FILE *cfg_yyin;
 extern int cfg_yylex(cfg_t *cfg);
+extern void cfg_yylex_destroy();
 extern int cfg_lexer_include(cfg_t *cfg, const char *fname);
 extern void cfg_scan_string_begin(const char *buf);
 extern void cfg_scan_string_end(void);
@@ -1360,6 +1361,8 @@ DLLIMPORT void cfg_free(cfg_t *cfg)
     free(cfg->filename);
 
     free(cfg);
+
+    cfg_yylex_destroy();
 }
 
 DLLIMPORT int cfg_include(cfg_t *cfg, cfg_opt_t *opt, int argc,
--
2.0.0.rc0


----- End forwarded message -----

_______________________________________________
Confuse-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/confuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: [aurelien@aurel32.net: [PATCH] confuse: correctly free all memory]

Alvaro Gamez
Hi,

I know that at least one piece of software (turnserver.sf.net)
re-exports this call
http://turnserver.sourceforge.net/doxygen/conf_8c.html#a71e08da844f7419a321969fa3f125fc9
with comment

Free the resources used by the lex parser.

This function comes from libconfuse and is not called in cfg_free(),
that's why call it here.

Regards


2014-06-03 13:33 GMT+02:00 Martin Hedenfalk <[hidden email]>:

> Aurelien, I took the liberty of forwarding your patch to the mailing list for
> wider testing.
>
> I'm looking for confirmation that this doesn't break anything.
>
>         .martin
>
> ----- Forwarded message from Aurelien Jarno <[hidden email]> -----
>
> Date: Sat, 24 May 2014 16:41:02 +0200
> From: Aurelien Jarno <[hidden email]>
> To: [hidden email]
> Cc: Aurelien Jarno <[hidden email]>
> Subject: [PATCH] confuse: correctly free all memory
> X-Mailer: git-send-email 2.0.0.rc0
>
> When calling cfg_free(), we also have to free the memory allocated by
> the lexer to avoid memory leak.
>
> Signed-off-by: Aurelien Jarno <[hidden email]>
> ---
>  src/confuse.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/src/confuse.c b/src/confuse.c
> index 5e0dcee..b01a01a 100644
> --- a/src/confuse.c
> +++ b/src/confuse.c
> @@ -50,6 +50,7 @@
>
>  extern FILE *cfg_yyin;
>  extern int cfg_yylex(cfg_t *cfg);
> +extern void cfg_yylex_destroy();
>  extern int cfg_lexer_include(cfg_t *cfg, const char *fname);
>  extern void cfg_scan_string_begin(const char *buf);
>  extern void cfg_scan_string_end(void);
> @@ -1360,6 +1361,8 @@ DLLIMPORT void cfg_free(cfg_t *cfg)
>      free(cfg->filename);
>
>      free(cfg);
> +
> +    cfg_yylex_destroy();
>  }
>
>  DLLIMPORT int cfg_include(cfg_t *cfg, cfg_opt_t *opt, int argc,
> --
> 2.0.0.rc0
>
>
> ----- End forwarded message -----
>
> _______________________________________________
> Confuse-devel mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/confuse-devel



--
Álvaro Gámez Machado

_______________________________________________
Confuse-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/confuse-devel