shithub: riscv

Download patch

ref: d48dcf08aa78e08ea17414cc59ea5210c4aad890
parent: 20da5094d9398dd64ab89c7dfc99f53ce6500842
author: cinap_lenrek <[email protected]>
date: Tue Jul 28 08:06:29 EDT 2015

cc: provide fake realloc() for getenv()

--- a/sys/src/cmd/cc/compat.c
+++ b/sys/src/cmd/cc/compat.c
@@ -17,11 +17,21 @@
 }
 
 void*
-realloc(void*, ulong)
+realloc(void *o, ulong n)
 {
-	fprint(2, "realloc called\n");
-	abort();
-	return 0;
+	ulong m;
+	void *a;
+
+	if(n == 0)
+		return nil;
+	if(o == nil)
+		return alloc(n);
+	a = alloc(n);
+	m = (char*)a - (char*)o;
+	if(m < n)
+		n = m;
+	memmove(a, o, n);
+	return a;
 }
 
 void
@@ -43,5 +53,10 @@
 
 void
 setmalloctag(void*, uintptr)
+{
+}
+
+void
+setrealloctag(void*, uintptr)
 {
 }