← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba

 

Paul J. Lucas has proposed merging lp:~paul-lucas/zorba/pjl-misc into lp:zorba.

Commit message:
Fixed as many obviously bad uses of unique_ptr<T>::release() as I could find.

Requested reviews:
  Paul J. Lucas (paul-lucas)

For more details, see:
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/190293

Fixed as many obviously bad uses of unique_ptr<T>::release() as I could find.
-- 
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/190293
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/compiler/codegen/plan_visitor.cpp'
--- src/compiler/codegen/plan_visitor.cpp	2013-09-23 09:11:02 +0000
+++ src/compiler/codegen/plan_visitor.cpp	2013-10-10 03:56:01 +0000
@@ -578,7 +578,8 @@
   lDummyIter->setFunctionArity(v.getFunctionArity());
   lDummyIter->setFunctionLocation(v.getFunctionLocation());
   lDummyIter->setFunctionCallLocation(v.getFunctionCallLocation());
-  push_itstack(lDummyIter.release());
+  push_itstack(lDummyIter.get());
+  lDummyIter.release();
 }
 
 bool begin_visit(wrapper_expr& v)
@@ -2038,10 +2039,13 @@
                                        flworExpr.get_loc(),
                                        forletClauses,
                                        whereIter,
-                                       groupClause.release(),
-                                       orderClause.release(),
-                                       materializeClause.release(),
+                                       groupClause.get(),
+                                       orderClause.get(),
+                                       materializeClause.get(),
                                        returnIter);
+  groupClause.release();
+  orderClause.release();
+  materializeClause.release();
   push_itstack(flworIter);
 }
 
@@ -2356,7 +2360,8 @@
     lDebugIterator->setParent(theDebuggerStack.top());
   }
 
-  push_itstack(lDebugIterator.release());
+  push_itstack(lDebugIterator.get());
+  lDebugIterator.release();
 }
 #endif
 

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2013-10-03 04:14:17 +0000
+++ src/compiler/translator/translator.cpp	2013-10-10 03:56:01 +0000
@@ -1788,7 +1788,8 @@
   inlineUDF->setArgVars(argVars);
   inlineUDF->setOptimized(true);
 
-  inlineFuncExpr->set_function(inlineUDF.release(), inlineUDF->numArgs());
+  inlineFuncExpr->set_function(inlineUDF.get(), inlineUDF->numArgs());
+  inlineUDF.release();
 
   // pop the scope.
   pop_scope();
@@ -12985,7 +12986,8 @@
   // because the function item expression may be a forward refereence to a real
   // UDF, in which case udf->numArgs() returns 0 since the UDF declaration has
   // not been fully processed yet.  
-  fiExpr->set_function(udf.release(), arity);
+  fiExpr->set_function(udf.get(), arity);
+  udf.release();
 
   return fiExpr;
 }

=== modified file 'src/runtime/core/flwor_iterator.cpp'
--- src/runtime/core/flwor_iterator.cpp	2013-09-17 21:12:49 +0000
+++ src/runtime/core/flwor_iterator.cpp	2013-10-10 03:56:01 +0000
@@ -1535,7 +1535,8 @@
       nongroupingSpecs[i].reset(planState);
     }
 
-    groupMap->insert(groupTuple.release(), nongroupVarSequences);
+    groupMap->insert(groupTuple.get(), nongroupVarSequences);
+    groupTuple.release();
   }
 }
 

=== modified file 'src/runtime/core/gflwor/groupby_iterator.cpp'
--- src/runtime/core/gflwor/groupby_iterator.cpp	2013-09-17 21:12:49 +0000
+++ src/runtime/core/gflwor/groupby_iterator.cpp	2013-10-10 03:56:01 +0000
@@ -416,7 +416,8 @@
       theNonGroupingSpecs[i].theInput->reset(aPlanState);
     }
 
-    groupMap->insert(groupTuple.release(), nonGroupTuple);
+    groupMap->insert(groupTuple.get(), nonGroupTuple);
+    groupTuple.release();
   }
 }
 

=== modified file 'src/runtime/core/internal_operators.cpp'
--- src/runtime/core/internal_operators.cpp	2013-02-07 17:24:36 +0000
+++ src/runtime/core/internal_operators.cpp	2013-10-10 03:56:01 +0000
@@ -69,7 +69,8 @@
       state->theDone = true;
       std::unique_ptr<ZorbaException> ze( clone( e ) );
 
-      GENV_ITEMFACTORY->createError(result, ze.release());
+      GENV_ITEMFACTORY->createError(result, ze.get());
+      ze.release();
     }
 
     STACK_PUSH(error || !state->theDone, state);

=== modified file 'src/runtime/full_text/ft_module_impl.cpp'
--- src/runtime/full_text/ft_module_impl.cpp	2013-10-08 00:56:10 +0000
+++ src/runtime/full_text/ft_module_impl.cpp	2013-10-10 03:56:01 +0000
@@ -678,7 +678,8 @@
 
   state->callback_.set_tokens( state->tokens_ );
   state->langs_.push( lang );
-  state->tokenizers_.push( tokenizer.release() );
+  state->tokenizers_.push( tokenizer.get() );
+  tokenizer.release();
 
   while ( true ) {
     if ( state->tokens_.empty() ) {
@@ -712,7 +713,8 @@
           if ( find_lang_attribute( *inc, &lang ) ) {
             state->langs_.push( lang );
             tokenizer = get_tokenizer( lang, &state->t_state_, loc );
-            state->tokenizers_.push( tokenizer.release() );
+            state->tokenizers_.push( tokenizer.get() );
+            tokenizer.release();
             add_sentinel = true;
           }
           // no break;

=== modified file 'src/runtime/hof/fn_hof_functions_impl.cpp'
--- src/runtime/hof/fn_hof_functions_impl.cpp	2013-09-17 21:12:49 +0000
+++ src/runtime/hof/fn_hof_functions_impl.cpp	2013-10-10 03:56:01 +0000
@@ -170,7 +170,8 @@
 
     if (fiInfo->numInScopeVars() > 0)
     {
-      result = new FunctionItem(fiInfo, fiDctx.release());
+      result = new FunctionItem(fiInfo, fiDctx.get());
+      fiDctx.release();
     }
     else
     {

=== modified file 'src/runtime/hof/function_item_iter.cpp'
--- src/runtime/hof/function_item_iter.cpp	2013-08-14 08:46:44 +0000
+++ src/runtime/hof/function_item_iter.cpp	2013-10-10 03:56:01 +0000
@@ -94,7 +94,8 @@
         theFunctionItemInfo->theQName = child->theFunctionItemInfo->theQName;
     }
 
-    result = new FunctionItem(theFunctionItemInfo, evalDctx.release());
+    result = new FunctionItem(theFunctionItemInfo, evalDctx.get());
+    evalDctx.release();
   }
   else
   {

=== modified file 'src/runtime/json/jsoniq_functions_impl.cpp'
--- src/runtime/json/jsoniq_functions_impl.cpp	2013-09-23 09:11:02 +0000
+++ src/runtime/json/jsoniq_functions_impl.cpp	2013-10-10 03:56:01 +0000
@@ -656,8 +656,9 @@
 
     GENV_ITEMFACTORY->createString(names.at(1), valueKey);
     GENV_ITEMFACTORY->createStreamableString(
-        values.at(1), *lResultStream.release(),
+        values.at(1), *lResultStream.get(),
         FnSerializeIterator::streamReleaser, true);
+    lResultStream.release();
   }
 
   GENV_ITEMFACTORY->createJSONObject(aResult, names, values);

=== modified file 'src/runtime/parsing_and_serializing/parsing_and_serializing_impl.cpp'
--- src/runtime/parsing_and_serializing/parsing_and_serializing_impl.cpp	2013-09-26 07:38:44 +0000
+++ src/runtime/parsing_and_serializing/parsing_and_serializing_impl.cpp	2013-10-10 03:56:01 +0000
@@ -254,7 +254,8 @@
       // and now serialize
       std::unique_ptr<std::stringstream> lResultStream(new std::stringstream());
       lSerializer.serialize(lIterWrapper, *lResultStream.get());
-      GENV_ITEMFACTORY->createStreamableString(aResult, *lResultStream.release(), FnSerializeIterator::streamReleaser, true);
+      GENV_ITEMFACTORY->createStreamableString(aResult, *lResultStream.get(), FnSerializeIterator::streamReleaser, true);
+      lResultStream.release();
     }
   }
   STACK_PUSH(true, lState);

=== modified file 'src/runtime/sequences/sequences_impl.cpp'
--- src/runtime/sequences/sequences_impl.cpp	2013-09-23 09:11:02 +0000
+++ src/runtime/sequences/sequences_impl.cpp	2013-10-10 03:56:01 +0000
@@ -2174,9 +2174,10 @@
   //creates stream item
   GENV_ITEMFACTORY->createStreamableString(
     oResult,
-    *lStream.release(),
+    *lStream.get(),
     lStream.get_deleter()
-    );
+  );
+  lStream.release();
 
   if (oResult.isNull())
   {

=== modified file 'src/store/api/item_handle.h'
--- src/store/api/item_handle.h	2013-04-04 02:09:34 +0000
+++ src/store/api/item_handle.h	2013-10-10 03:56:01 +0000
@@ -70,6 +70,7 @@
   void setNull() { p = NULL; }
 
   T* getp() const { return p; }
+  T* get() const { return p; }          // synonym to match unique_ptr
 
   union_T getp_ref() { union_T u_t; u_t.t = &p; return u_t;}
 

=== modified file 'src/store/naive/atomic_items.cpp'
--- src/store/naive/atomic_items.cpp	2013-07-30 18:35:31 +0000
+++ src/store/naive/atomic_items.cpp	2013-10-10 03:56:01 +0000
@@ -1979,7 +1979,9 @@
       theValue.data(), theValue.size(), lang, wildcards, callback
     );
 
-  return FTTokenIterator_t( new NaiveFTTokenIterator( tokens.release() ) );
+  FTTokenIterator *const temp = new NaiveFTTokenIterator( tokens.get() );
+  tokens.release();
+  return FTTokenIterator_t( temp );
 }
 #endif /* ZORBA_NO_FULL_TEXT */
 

=== modified file 'src/store/naive/node_iterators.cpp'
--- src/store/naive/node_iterators.cpp	2013-06-15 02:57:08 +0000
+++ src/store/naive/node_iterators.cpp	2013-10-10 03:56:01 +0000
@@ -290,7 +290,8 @@
         return true;
       }
 
-      theNodes.push_back(reinterpret_cast<XmlNode*>(item.release()));
+      theNodes.push_back(reinterpret_cast<XmlNode*>(item.get()));
+      item.release();
     }
     
     // We are out of items. We can now begin to output the nodes. In the next
@@ -422,7 +423,8 @@
         theNodeMode = true;
       }
 
-      theNodes.push_back(reinterpret_cast<XmlNode*>(result.release()));
+      theNodes.push_back(reinterpret_cast<XmlNode*>(result.get()));
+      result.release();
     }
 
     ComparisonFunction cmp;

=== modified file 'src/store/naive/simple_lazy_temp_seq.cpp'
--- src/store/naive/simple_lazy_temp_seq.cpp	2013-05-08 20:14:47 +0000
+++ src/store/naive/simple_lazy_temp_seq.cpp	2013-10-10 03:56:01 +0000
@@ -80,7 +80,8 @@
   }
   else
   {
-    theItems.push_back(item.release());
+    theItems.push_back(item.get());
+    item.release();
   }
 }
 

=== modified file 'src/util/zorba_regex_engine.cpp'
--- src/util/zorba_regex_engine.cpp	2013-09-17 21:12:49 +0000
+++ src/util/zorba_regex_engine.cpp	2013-10-10 03:56:01 +0000
@@ -830,7 +830,8 @@
         throw XQUERY_EXCEPTION( err::FORX0002, ERROR_PARAMS(pattern, ZED(REGEX_MULTICHAR_IN_CHAR_RANGE)) );
       }
       //chargroup->addMultiChar(c1, multichar_type);
-      chargroup->addCharMatch(charmatch.release());
+      chargroup->addCharMatch(charmatch.get());
+      charmatch.release();
       *chargroup_len += c1_len;
       continue;
     }
@@ -841,7 +842,8 @@
       {
         //chargroup->addOneChar(c1);
         //chargroup->addOneChar('-');
-        chargroup->addCharMatch(charmatch.release());
+        chargroup->addCharMatch(charmatch.get());
+        charmatch.release();
         chargroup->addCharMatch(new CRegexXQuery_char_ascii(current_regex, '-'));
         (*chargroup_len)++;
         continue;
@@ -887,7 +889,8 @@
       }
     }
     //chargroup->addOneChar(c1);
-    chargroup->addCharMatch(charmatch.release());
+    chargroup->addCharMatch(charmatch.get());
+    charmatch.release();
   }
   if(pattern[*chargroup_len])
     (*chargroup_len)++;

=== modified file 'src/zorbatypes/rchandle.h'
--- src/zorbatypes/rchandle.h	2013-06-27 15:54:27 +0000
+++ src/zorbatypes/rchandle.h	2013-10-10 03:56:01 +0000
@@ -221,6 +221,7 @@
   void setNull() { p = NULL;}
 
   T* getp() const { return p; }
+  T* get() const { return p; }          // synonym to match unique_ptr
 
   union_T getp_ref() { union_T u_t; u_t.t = &p; return u_t;}
 


Follow ups