diff options
author | sachin gupta <sgupta2m@in.ibm.com> | 2013-03-19 02:17:31 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2013-04-02 17:34:35 -0500 |
commit | d3dd93c04ac775170ea0c129ca06c0be521c8947 (patch) | |
tree | 235b1f15ee56a2cc45c4d39bf8b7fcf1ac05fe56 /src/usr/diag | |
parent | 036dc9110acd7977f4b20809b26632e01d4304ca (diff) | |
download | talos-hostboot-d3dd93c04ac775170ea0c129ca06c0be521c8947.tar.gz talos-hostboot-d3dd93c04ac775170ea0c129ca06c0be521c8947.zip |
PRD: Add NULL checks for memory in FlyWeight
Change-Id: If655cf403ace276f9d9a0d71ed016a5316148204
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/3617
Tested-by: Jenkins Server
Reviewed-by: Christopher T. Phan <cphan@us.ibm.com>
Reviewed-by: Zane Shelley <zshelle@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/3829
Diffstat (limited to 'src/usr/diag')
-rwxr-xr-x | src/usr/diag/prdf/common/util/prdfFlyWeight.C | 4 | ||||
-rwxr-xr-x | src/usr/diag/prdf/common/util/prdfFlyWeightS.C | 18 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/usr/diag/prdf/common/util/prdfFlyWeight.C b/src/usr/diag/prdf/common/util/prdfFlyWeight.C index 151e49ae6..05df37a00 100755 --- a/src/usr/diag/prdf/common/util/prdfFlyWeight.C +++ b/src/usr/diag/prdf/common/util/prdfFlyWeight.C @@ -36,6 +36,7 @@ #include <tracinterface.H> #include <prdfHeapBucketSize.H> #include <prdfTrace.H> +#include <prdfAssert.h> #undef prdfFlyWeight_C //---------------------------------------------------------------------- @@ -114,7 +115,8 @@ T & FlyWeight<T,S>::get(const T & key) current_array = new T[RoundBucketSize<T,S>::value]; if(current_array == NULL) // dg00a { // dg00a - PRDF_TRAC("PRDF Could not get requested memory"); // dg00a + PRDF_ERR("PRDF Could not get requested memory"); + PRDF_ASSERT( NULL != current_array ); } // dg00a // if the heap of array ptrs is full(or non-existant) then increase capacity by S dg00a if(iv_heap.size() == iv_heap.capacity()) // dg00a diff --git a/src/usr/diag/prdf/common/util/prdfFlyWeightS.C b/src/usr/diag/prdf/common/util/prdfFlyWeightS.C index 8a8a73789..325fa729b 100755 --- a/src/usr/diag/prdf/common/util/prdfFlyWeightS.C +++ b/src/usr/diag/prdf/common/util/prdfFlyWeightS.C @@ -24,6 +24,8 @@ #include <prdfFlyWeightS.H> #include <algorithm> #include <prdfHeapBucketSize.H> +#include <prdfTrace.H> +#include <prdfAssert.h> namespace PRDF { @@ -201,7 +203,13 @@ T * FlyWeightS<T,S>::getHeap() if (NULL == iv_nextPos) { - iv_heaps.push_back(iv_nextPos = new T[RoundBucketSize<T,S>::value]); + iv_nextPos = new T[RoundBucketSize<T,S>::value]; + if( NULL == iv_nextPos ) + { + PRDF_ERR("Can not allocate memory on heap"); + PRDF_ASSERT( NULL != iv_nextPos ); + } + iv_heaps.push_back(iv_nextPos); } T * l_rc = iv_nextPos; @@ -209,7 +217,13 @@ T * FlyWeightS<T,S>::getHeap() iv_nextPos++; if ((static_cast<T*>(*(iv_heaps.end()-1)) + RoundBucketSize<T,S>::value) == iv_nextPos) { - iv_heaps.push_back(iv_nextPos = new T[RoundBucketSize<T,S>::value]); + iv_nextPos = new T[RoundBucketSize<T,S>::value]; + if( NULL == iv_nextPos ) + { + PRDF_ERR("Can not allocate memory on heap"); + PRDF_ASSERT( NULL != iv_nextPos ); + } + iv_heaps.push_back(iv_nextPos); } return l_rc; |