Plan 9 from Bell Labs’s /usr/web/sources/plan9/sys/src/cmd/aquarela/smballoc.c

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


#include "headers.h"

#ifndef LEAK
void *
smbemallocz(ulong size, int clear)
{
	void *p = nbemalloc(size);
	if (clear && p)
		memset(p, 0, size);
	return p;
}

void *
smbemalloc(ulong size)
{
	return smbemallocz(size, 0);
}

char *
smbestrdup(char *p)
{
	char *q;
	q = smbemalloc(strlen(p) + 1);
	return strcpy(q, p);
}
#endif

void
smbfree(void **pp)
{
	void *p = *pp;
	if (p) {
		free(p);
		*pp = nil;
	}
}

void
smberealloc(void **pp, ulong size)
{
	*pp = realloc(*pp, size);
	assert(size == 0 || *pp);
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].