shithub: qk1

Download patch

ref: 32a886a42047965215cf1a097d0e316d63455186
parent: 35722088b80018e49c5b1707a1028eefb8a9dee9
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Wed Dec 27 17:41:15 EST 2023

zone: add Hunk_Free

--- a/zone.c
+++ b/zone.c
@@ -115,6 +115,25 @@
 	}
 }
 
+void
+Hunk_Free(void *p)
+{
+	mem_t *m;
+
+	if(p == nil)
+		return;
+	m = p;
+	m--;
+
+	if(m->prev != nil)
+		m->prev->next = m->next;
+	if(m->next != nil)
+		m->next->prev = m->prev;
+	if(m == hunk_head)
+		hunk_head = m->next;
+	free(m);
+}
+
 void *
 Hunk_TempAlloc(int size)
 {
--- a/zone.h
+++ b/zone.h
@@ -12,6 +12,7 @@
 void *Hunk_Double(void *p);
 void *Hunk_Mark(void);
 void Hunk_FreeToMark(void *mark);
+void Hunk_Free(void *p);
 void *Hunk_TempAlloc(int size);
 
 void *Cache_Alloc(mem_user_t *c, int size);