use nothrow for allocation

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27707 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2008-09-23 12:41:42 +00:00
parent 671fe092d3
commit 92ed85c9ec
2 changed files with 16 additions and 20 deletions

View File

@ -9,6 +9,8 @@
#include <GameSoundDefs.h> #include <GameSoundDefs.h>
#include <MediaDefs.h> #include <MediaDefs.h>
#include <new>
#include "GSUtility.h" #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); bigtime_t sec = bigtime_t(duration / 1000000.0);
float inc = diff * 200; float inc = diff * 200;
_gs_ramp* ramp = new _gs_ramp; _gs_ramp* ramp = new (std::nothrow) _gs_ramp;
ramp->value = value; if (ramp != NULL) {
ramp->value = value;
ramp->frame_total = frames * sec; ramp->frame_total = frames * sec;
ramp->frame_inc = int(ramp->frame_total / inc); ramp->frame_inc = int(ramp->frame_total / inc);
ramp->inc = (set - *value) / inc; ramp->inc = (set - *value) / inc;
ramp->frame_count = 0; ramp->frame_count = 0;
ramp->frame_inc_count = 0; ramp->frame_inc_count = 0;
ramp->duration = duration;
ramp->duration = duration;
}
return ramp; return ramp;
} }
@ -45,8 +48,7 @@ ChangeRamp(_gs_ramp* ramp)
if (ramp->frame_inc_count >= ramp->frame_inc) { if (ramp->frame_inc_count >= ramp->frame_inc) {
ramp->frame_inc_count = 0; ramp->frame_inc_count = 0;
*ramp->value += ramp->inc; *ramp->value += ramp->inc;
} } else
else
ramp->frame_inc_count++; ramp->frame_inc_count++;
ramp->frame_count++; ramp->frame_count++;
@ -80,7 +82,9 @@ get_sample_size(int32 format)
sample = sizeof(float); sample = sizeof(float);
break; break;
default: sample = 0; default:
sample = 0;
break;
} }
return sample; return sample;

View File

@ -27,17 +27,9 @@
#ifndef _GAMESOUND_UTILITY_H #ifndef _GAMESOUND_UTILITY_H
#define _GAMESOUND_UTILITY_H #define _GAMESOUND_UTILITY_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
// Project Includes ------------------------------------------------------------
#include <GameSoundDefs.h> #include <GameSoundDefs.h>
#include <MediaDefs.h> #include <MediaDefs.h>
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
struct _gs_ramp struct _gs_ramp
{ {