]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: keep bufferlist on the stack
authorYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 19 May 2009 22:30:22 +0000 (15:30 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 19 May 2009 23:01:58 +0000 (16:01 -0700)
src/librados.cc

index 8592ddbf4894a2bde23fdf93b465742fc2b914bb..e410c3f899bd6769e26132d3cd8ab0dc59002fc9 100644 (file)
@@ -328,11 +328,11 @@ int RadosClient::exec(int pool, object_t& oid, const char *cls, const char *meth
 int RadosClient::read(int pool, object_t& oid, char *buf, off_t off, size_t len)
 {
   SnapContext snapc;
-  bufferlist *bl = new bufferlist;
+  bufferlist bl;
   Mutex lock("RadosClient::read");
   Cond read_wait;
 
-  C_ReadCommit *oncommit = new C_ReadCommit(oid, off, &len, bl, &read_wait);
+  C_ReadCommit *oncommit = new C_ReadCommit(oid, off, &len, &bl, &read_wait);
 
   ceph_object_layout layout = objecter->osdmap->make_object_layout(oid, pool);
 
@@ -341,7 +341,7 @@ int RadosClient::read(int pool, object_t& oid, char *buf, off_t off, size_t len)
   lock.Lock();
 
   objecter->read(oid, layout,
-             off, len, CEPH_NOSNAP, bl, 0,
+             off, len, CEPH_NOSNAP, &bl, 0,
               oncommit);
 
   dout(0) << "after read call" << dendl;
@@ -350,9 +350,7 @@ int RadosClient::read(int pool, object_t& oid, char *buf, off_t off, size_t len)
   lock.Unlock();
 
   if (len)
-    memcpy(buf, bl->c_str(), len);
-
-  delete bl;
+    memcpy(buf, bl.c_str(), len);
 
   return len;
 }