2
* Purpose: OSS memory block allocation and management routines.
6
* This file is part of Open Sound System.
8
* Copyright (C) 4Front Technologies 1996-2008.
10
* This this source file is released under GPL v2 license (no other versions).
11
* See the COPYING file included in the main directory of this source
12
* distribution for the license terms and conditions.
16
#include <oss_config.h>
24
oss_memblk_t *oss_global_memblk=NULL;
27
*oss_memblk_malloc(oss_memblk_t **blk, int size)
31
newblk = KERNEL_MALLOC (sizeof(oss_memblk_t) + size);
33
newblk->addr = newblk +1;
39
* No earlier memory blocks in the chain.
46
* Add this block to the chain.
55
oss_memblk_free(oss_memblk_t **blk, void *addr)
57
oss_memblk_t *this_one = *blk, *prev = NULL;
59
while (this_one != NULL)
61
if (this_one->addr == addr)
63
if (prev == NULL) /* First one in the chain */
65
*blk = this_one->next;
66
KERNEL_FREE (this_one);
70
prev->next = this_one->next;
71
KERNEL_FREE (this_one);
77
this_one = this_one->next;
82
oss_memblk_unalloc(oss_memblk_t **blk)
85
* Free all memory allocations on the chain.
87
oss_memblk_t *this_one = *blk;
89
while (this_one != NULL)
91
oss_memblk_t *next_one;
93
next_one = this_one->next;
95
KERNEL_FREE(this_one);