示例#1
0
文件: mvar.c 项目: strager/mvar
MVar *
mvar_new (void *value)
{
	MVar *mvar = malloc (sizeof (*mvar));
	if (mvar == NULL) {
		return NULL;
	}
	if (!mvar_init (mvar, value)) {
		free (mvar);
		return NULL;
	}
	return mvar;
}
示例#2
0
MVar *
mvar_new (void *const value)
{
	int e = 0;
	MVar *mvar = malloc (sizeof (MVar));
	if (!mvar) {
		e = errno;
		KNOWN_ERRORS_1 (e, ENOMEM);
		RECOVERABLE_1 (e, e_alloc, ENOMEM);
	}

	e = mvar_init (mvar, value);
	KNOWN_ERRORS_2 (e, EAGAIN, ENOMEM);
	RECOVERABLE_2 (e, e_init, EAGAIN, ENOMEM);

	return mvar;

e_init:

	free (mvar);
e_alloc:

	return NULL;
}