aboutsummaryrefslogtreecommitdiffstats
path: root/sdk/other/memrelease.c
blob: 144bff69e8481cb69ef1db828d66be309313e07d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * Relallocate and release memory pools.
 * $Id$
 * Copyright (c) 1997 by Tycho Softworks.
 * For conditions of distribution and reuse see product license.
 */

#include <other/memory.h>

void	memrelease(MEMPOOL *mem)
{
	MEMPAGE	*page = memfirst(mem);
	MEMPAGE	*next;

	while(page)
	{
		next = page->page_next;
		free(page);
		page = next;
	}
}

void	memreuse(MEMPOOL *mem)
{
	MEMPAGE	*page = memfirst(mem);
	MEMPAGE	*next;

	page = page->page_next;
	while(page)
	{
		next = page->page_next;
		free(page);
		page = next;
	}
	mem->mem_pused = 1;
	mem->mem_free = NULL;
	page = mem->mem_last = memfirst(mem);
	page->page_used = 0;
	page->page_next = NULL;
}