mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-28 10:59:16 -04:00
c414fb40d2
(cherry picked from commit 021b65cf2d)
20 lines
641 B
C
20 lines
641 B
C
#ifndef PSX_SOURCE_OBSERVER_LIMIT_H
|
|
#define PSX_SOURCE_OBSERVER_LIMIT_H
|
|
#include <stdlib.h>
|
|
/* A declared route may exceed the historical short-TAS diagnostic bound.
|
|
* Reject signs, whitespace, overflow and unbounded collection. */
|
|
static inline unsigned source_observer_max_frames(const char *variable) {
|
|
const char *limit=getenv(variable);
|
|
if(!limit)return 20000;
|
|
unsigned value=0;
|
|
if(!*limit)abort();
|
|
for(const char *p=limit;*p;++p) {
|
|
if(*p<'0'||*p>'9'||value>100000)abort();
|
|
value=value*10+(unsigned)(*p-'0');
|
|
if(value>1000000)abort();
|
|
}
|
|
if(!value)abort();
|
|
return value;
|
|
}
|
|
#endif
|