diff options
author | Jiří Pinkava <j-pi@seznam.cz> | 2015-03-12 11:23:16 +0100 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2015-03-22 08:00:16 -0700 |
commit | f042e44d18c481e7e2ca37895afbd6ecf42061a3 (patch) | |
tree | b4bb46ef4613109ab700b5960769e115d24b4aee /gnuradio-runtime/lib/vmcircbuf_prefs.cc | |
parent | 1e573fa391122fa00470df07790f1f1e5f73f700 (diff) |
runtime: do not return buffer created on stact #722
Diffstat (limited to 'gnuradio-runtime/lib/vmcircbuf_prefs.cc')
-rw-r--r-- | gnuradio-runtime/lib/vmcircbuf_prefs.cc | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/gnuradio-runtime/lib/vmcircbuf_prefs.cc b/gnuradio-runtime/lib/vmcircbuf_prefs.cc index 258605c6be..a786b8a881 100644 --- a/gnuradio-runtime/lib/vmcircbuf_prefs.cc +++ b/gnuradio-runtime/lib/vmcircbuf_prefs.cc @@ -65,11 +65,9 @@ namespace gr { fs::create_directory(path); } - const char * - vmcircbuf_prefs::get(const char *key) + int + vmcircbuf_prefs::get(const char *key, char *value, int value_size) { - static char buf[1024]; - gr::thread::scoped_lock guard(s_vm_mutex); FILE *fp = fopen(pathname (key), "r"); @@ -78,17 +76,17 @@ namespace gr { return 0; } - memset(buf, 0, sizeof (buf)); - size_t ret = fread(buf, 1, sizeof(buf) - 1, fp); - if(ret == 0) { + const size_t ret = fread(value, 1, value_size - 1, fp); + value[ret] = '\0'; + if(ret == 0 && !feof(fp)) { if(ferror(fp) != 0) { perror(pathname (key)); fclose(fp); - return 0; + return -1; } } fclose(fp); - return buf; + return ret; } void |