* [PATCH BlueZ] Fix memory allocation in Proximity Monitor
@ 2011-08-03 14:25 Claudio Takahasi
2011-08-08 10:23 ` Johan Hedberg
0 siblings, 1 reply; 2+ messages in thread
From: Claudio Takahasi @ 2011-08-03 14:25 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
textfile get functions returns memory allocated using malloc. String
is now being re-allocated using glib functions to keep the code standard
in the Proximity Monitor code.
---
proximity/monitor.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/proximity/monitor.c b/proximity/monitor.c
index d068142..a3cb8ef 100644
--- a/proximity/monitor.c
+++ b/proximity/monitor.c
@@ -91,13 +91,21 @@ static char *read_proximity_config(bdaddr_t *sba, bdaddr_t *dba,
const char *alert)
{
char filename[PATH_MAX + 1], addr[18], key[38];
+ char *str, *strnew;
create_filename(filename, PATH_MAX, sba, "proximity");
ba2str(dba, addr);
snprintf(key, sizeof(key), "%17s#%s", addr, alert);
- return textfile_caseget(filename, key);
+ str = textfile_caseget(filename, key);
+ if (str == NULL)
+ return NULL;
+
+ strnew = g_strdup(str);
+ free(str);
+
+ return strnew;
}
static void char_discovered_cb(GSList *characteristics, guint8 status,
--
1.7.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH BlueZ] Fix memory allocation in Proximity Monitor
2011-08-03 14:25 [PATCH BlueZ] Fix memory allocation in Proximity Monitor Claudio Takahasi
@ 2011-08-08 10:23 ` Johan Hedberg
0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2011-08-08 10:23 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
Hi Claudio,
On Wed, Aug 03, 2011, Claudio Takahasi wrote:
> textfile get functions returns memory allocated using malloc. String
> is now being re-allocated using glib functions to keep the code standard
> in the Proximity Monitor code.
> ---
> proximity/monitor.c | 10 +++++++++-
> 1 files changed, 9 insertions(+), 1 deletions(-)
Applied. Thanks.
Johan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-08-08 10:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-03 14:25 [PATCH BlueZ] Fix memory allocation in Proximity Monitor Claudio Takahasi
2011-08-08 10:23 ` Johan Hedberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox