From 92ed85c9ec1991f091725c7331827fcfb9c590d3 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Tue, 23 Sep 2008 12:41:42 +0000 Subject: [PATCH] use nothrow for allocation git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27707 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/game/GSUtility.cpp | 28 ++++++++++++++++------------ src/kits/game/GSUtility.h | 8 -------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/kits/game/GSUtility.cpp b/src/kits/game/GSUtility.cpp index 2b18e7f879..ad64abb490 100644 --- a/src/kits/game/GSUtility.cpp +++ b/src/kits/game/GSUtility.cpp @@ -9,6 +9,8 @@ #include #include +#include + #include "GSUtility.h" @@ -19,19 +21,20 @@ InitRamp(float* value, float set, float frames, bigtime_t duration) bigtime_t sec = bigtime_t(duration / 1000000.0); float inc = diff * 200; - _gs_ramp* ramp = new _gs_ramp; - ramp->value = value; + _gs_ramp* ramp = new (std::nothrow) _gs_ramp; + if (ramp != NULL) { + ramp->value = value; - ramp->frame_total = frames * sec; - ramp->frame_inc = int(ramp->frame_total / inc); + ramp->frame_total = frames * sec; + ramp->frame_inc = int(ramp->frame_total / inc); - ramp->inc = (set - *value) / inc; + ramp->inc = (set - *value) / inc; - ramp->frame_count = 0; - ramp->frame_inc_count = 0; - - ramp->duration = duration; + ramp->frame_count = 0; + ramp->frame_inc_count = 0; + ramp->duration = duration; + } return ramp; } @@ -45,8 +48,7 @@ ChangeRamp(_gs_ramp* ramp) if (ramp->frame_inc_count >= ramp->frame_inc) { ramp->frame_inc_count = 0; *ramp->value += ramp->inc; - } - else + } else ramp->frame_inc_count++; ramp->frame_count++; @@ -80,7 +82,9 @@ get_sample_size(int32 format) sample = sizeof(float); break; - default: sample = 0; + default: + sample = 0; + break; } return sample; diff --git a/src/kits/game/GSUtility.h b/src/kits/game/GSUtility.h index 3dfcc4cc8f..f47ecea0f3 100644 --- a/src/kits/game/GSUtility.h +++ b/src/kits/game/GSUtility.h @@ -27,17 +27,9 @@ #ifndef _GAMESOUND_UTILITY_H #define _GAMESOUND_UTILITY_H -// Standard Includes ----------------------------------------------------------- - -// System Includes ------------------------------------------------------------- - -// Project Includes ------------------------------------------------------------ #include #include -// Local Includes -------------------------------------------------------------- - -// Local Defines --------------------------------------------------------------- struct _gs_ramp {