plan9port/src/lib9/malloc.c
Dan Cross 7bf2db4c2a malloc: remove locking
The issue manifests in fork: POSIX fork mandates that a
fork'd process is created with a single thread.  If a
multithreaded program forks, and some thread was in
malloc() when the fork() happened, then in the child
the lock will be held but there will be no thread to
release it.

We assume the system malloc() must already know how to
deal with this and is thread-safe, but it won't know about
our custom spinlock.  Judging that this is no longer
necessary (the lock code was added 15 years ago) we remove
it.

Signed-off-by: Dan Cross <cross@gajendra.net>
2020-01-16 16:54:19 +00:00

37 lines
423 B
C

/*
* These are here mainly so that I can link against
* debugmalloc.c instead and not recompile the world.
*/
#include <u.h>
#define NOPLAN9DEFINES
#include <libc.h>
void*
p9malloc(ulong n)
{
if(n == 0)
n++;
return malloc(n);
}
void
p9free(void *v)
{
free(v);
}
void*
p9calloc(ulong a, ulong b)
{
if(a*b == 0)
a = b = 1;
return calloc(a, b);
}
void*
p9realloc(void *v, ulong n)
{
return realloc(v, n);
}