Пример #1
0
/* should return $HOME/.[name] */
char *os_get_config_path(const char *name)
{
	char *path_ptr = getenv("HOME");
	if (path_ptr == NULL)
		bcrash("Could not get $HOME\n");

	struct dstr path;
	dstr_init_copy(&path, path_ptr);
	dstr_cat(&path, "/.");
	dstr_cat(&path, name);
	return path.array;
}
Пример #2
0
void *bmalloc(size_t size)
{
	void *ptr = alloc.malloc(size);
	if (!ptr && !size)
		ptr = alloc.malloc(1);
	if (!ptr)
		bcrash("Out of memory while trying to allocate %lu bytes",
				(unsigned long)size);

	num_allocs++;
	return ptr;
}
Пример #3
0
void *brealloc(void *ptr, size_t size)
{
	if (!ptr)
		num_allocs++;

	ptr = alloc.realloc(ptr, size);
	if (!ptr && !size)
		ptr = alloc.realloc(ptr, 1);
	if (!ptr)
		bcrash("Out of memory while trying to allocate %lu bytes",
				(unsigned long)size);

	return ptr;
}
Пример #4
0
static inline bool pointer_fixup_func(void *data,
		size_t idx, obs_hotkey_binding_t *binding)
{
	UNUSED_PARAMETER(idx);
	UNUSED_PARAMETER(data);

	size_t idx_;
	if (!find_id(binding->hotkey_id, &idx_)) {
		bcrash("obs-hotkey: Could not find hotkey id '%" PRIuMAX "' "
				"for binding '%s' (modifiers 0x%x)",
				(uintmax_t)binding->hotkey_id,
				obs_key_to_name(binding->key.key),
				binding->key.modifiers);
		binding->hotkey = NULL;
		return true;
	}

	binding->hotkey = &obs->hotkeys.hotkeys.array[idx_];

	return true;
}
static LONG CALLBACK exception_handler(PEXCEPTION_POINTERS exception)
{
	struct exception_handler_data data = {0};
	static bool inside_handler = false;

	/* don't use if a debugger is present */
	if (IsDebuggerPresent())
		return EXCEPTION_CONTINUE_SEARCH;

	if (inside_handler)
		return EXCEPTION_CONTINUE_SEARCH;

	inside_handler = true;

	handle_exception(&data, exception);
	bcrash(data.str.array);
	exception_handler_data_free(&data);

	inside_handler = false;

	return EXCEPTION_CONTINUE_SEARCH;
}