[Pkg-owncloud-commits] [owncloud-client] 152/333: Fix memory leak: Don't use raw pointers
Sandro Knauß
hefee-guest at moszumanska.debian.org
Thu Apr 17 23:16:47 UTC 2014
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit ba300c2fc1f3fd28d71bfe1f88916089f46b2096
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Mon Mar 17 10:04:42 2014 +0100
Fix memory leak: Don't use raw pointers
---
src/mirall/folderwatcher_linux.cpp | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/mirall/folderwatcher_linux.cpp b/src/mirall/folderwatcher_linux.cpp
index a8d522e..71226dc 100644
--- a/src/mirall/folderwatcher_linux.cpp
+++ b/src/mirall/folderwatcher_linux.cpp
@@ -22,6 +22,7 @@
#include <QDebug>
#include <QStringList>
#include <QObject>
+#include <QVarLengthArray>
namespace Mirall {
@@ -129,13 +130,10 @@ void FolderWatcherPrivate::slotReceivedNotification(int fd)
struct inotify_event* event;
int i;
int error;
- char *buffer = NULL;
- int buf_size = 2048;
-
- buffer = (char*) malloc(buf_size);
+ QVarLengthArray<char, 2048> buffer(2048);
do {
- len = read(fd, buffer, buf_size);
+ len = read(fd, buffer.data(), buffer.size());
error = errno;
/**
* From inotify documentation:
@@ -149,8 +147,7 @@ void FolderWatcherPrivate::slotReceivedNotification(int fd)
if (len < 0 && error == EINVAL)
{
// double the buffer size
- buf_size *= 2;
- buffer = (char *) realloc(buffer, buf_size);
+ buffer.resize(buffer.size() * 2);
/* and try again ... */
continue;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list