-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathassert.cpp
More file actions
43 lines (39 loc) · 1.05 KB
/
assert.cpp
File metadata and controls
43 lines (39 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//
// assert.cpp
// OpenRenderBox
#include <OpenRenderBoxCxx/Util/assert.hpp>
#include <OpenRenderBoxCxx/Util/log.hpp>
static char* error_message = nullptr;
namespace ORB {
void precondition_failure(const char *format, ...) {
char* s = nullptr;
va_list va;
va_start(va, format);
vasprintf(&s, format, va);
va_end(va);
if (s != nullptr) {
#if ORB_TARGET_OS_DARWIN
os_log_error(error_log(), "precondition failure: %s", s);
#endif /* ORB_TARGET_OS_DARWIN */
if (error_message == nullptr) {
asprintf(&error_message, "OpenRenderBox precondition failure: %s.\n", s);
}
free(s);
}
abort();
}
void non_fatal_precondition_failure(const char *format, ...) {
char* s = nullptr;
va_list va;
va_start(va, format);
vasprintf(&s, format, va);
va_end(va);
if (s != nullptr) {
#if ORB_TARGET_OS_DARWIN
os_log_fault(error_log(), "precondition failure: %s", s);
#endif /* ORB_TARGET_OS_DARWIN */
free(s);
}
return;
}
} /* ORB */