format squiggle.c
This commit is contained in:
parent
6247fbfb7b
commit
bebb7c6d46
10
squiggle.c
10
squiggle.c
|
@ -10,11 +10,9 @@
|
|||
#define EXIT_ON_ERROR 0
|
||||
#define PROCESS_ERROR(error_msg) process_error(error_msg, EXIT_ON_ERROR, __FILE__, __LINE__)
|
||||
|
||||
// PI constant
|
||||
const float PI = 3.14159265358979323846; // M_PI in gcc gnu99
|
||||
|
||||
// Pseudo Random number generator
|
||||
|
||||
uint32_t xorshift32(uint32_t* seed)
|
||||
{
|
||||
// Algorithm "xor" from p. 4 of Marsaglia, "Xorshift RNGs"
|
||||
|
@ -30,7 +28,6 @@ uint32_t xorshift32(uint32_t* seed)
|
|||
}
|
||||
|
||||
// Distribution & sampling functions
|
||||
|
||||
float rand_0_to_1(uint32_t* seed)
|
||||
{
|
||||
return ((float)xorshift32(seed)) / ((float)UINT32_MAX);
|
||||
|
@ -128,11 +125,12 @@ struct box {
|
|||
char* error_msg;
|
||||
};
|
||||
|
||||
struct box process_error(const char* error_msg, int should_exit, char* file, int line){
|
||||
if(should_exit){
|
||||
struct box process_error(const char* error_msg, int should_exit, char* file, int line)
|
||||
{
|
||||
if (should_exit) {
|
||||
printf("@, in %s (%d)", file, line);
|
||||
exit(1);
|
||||
}else{
|
||||
} else {
|
||||
char error_msg[MAX_ERROR_LENGTH];
|
||||
snprintf(error_msg, MAX_ERROR_LENGTH, "@, in %s (%d)", file, line);
|
||||
struct box error = { .empty = 1, .error_msg = error_msg };
|
||||
|
|
Loading…
Reference in New Issue
Block a user