Plan 9 from Bell Labs’s /usr/web/sources/contrib/quanstro/src/aoesnap/util.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <u.h>
#include <goo.h>
#include "snap.h"

static char *oom = "out of memory";

void*
emalloc(ulong n)
{
	void *v;

	v = malloc(n);
	if(!v)
		sysfatal(oom);
	memset(v, 0, n);
	return v;
}

void*
erealloc(void *v, ulong n)
{
	v = realloc(v, n);
	if(!v)
		sysfatal(oom);
	return v;
}

char*
estrdup(char *s)
{
	char *t;
	ulong l;

	l = strlen(s);
	t = emalloc(l+1);
	memmove(t, s, l);
	t[l] = 0;
	return t;
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.