shithub: riscv

ref: 1132d1b9df4c9ea2b857fa9778fe6762cd81ded8
dir: /sys/src/libc/9sys/privalloc.c/

View raw version
#include <u.h>
#include <libc.h>

static Lock	privlock;

extern void	**_privates;
extern int	_nprivates;

void **
privalloc(void)
{
	void **p;

	lock(&privlock);
	if(_nprivates > 0)
		p = &_privates[--_nprivates];
	else
		p = nil;
	unlock(&privlock);

	return p;
}