Updated PCI IDs to latest snapshot.
[tangerine.git] / compiler / clib / free.c
blob90fba6bc4af512a1f5c34cc9836cf68a93c5fcb5
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 ANSI C function free().
6 */
8 #include "__arosc_privdata.h"
9 #include "__memalign.h"
11 #include <exec/memory.h>
12 #include <proto/exec.h>
14 /*****************************************************************************
16 NAME */
17 #include <stdlib.h>
19 void free (
21 /* SYNOPSIS */
22 void * memory)
24 /* FUNCTION
25 Return memory allocated with malloc() or a similar function to the
26 system.
28 INPUTS
29 memory - The result of the previous call to malloc(), etc. or
30 NULL.
32 RESULT
33 None.
35 NOTES
36 This function must not be used in a shared library or in a threaded
37 application.
39 EXAMPLE
41 BUGS
43 SEE ALSO
44 malloc()
46 INTERNALS
48 ******************************************************************************/
50 if (memory)
52 unsigned char *mem;
53 size_t size;
55 mem = ((UBYTE *)memory) - AROS_ALIGN(sizeof(size_t));
57 size = *((size_t *) mem);
58 if (size == MEMALIGN_MAGIC)
59 free(((void **) mem)[-1]);
60 else {
61 size += AROS_ALIGN(sizeof(size_t));
62 FreePooled (__startup_mempool, mem, size);
66 } /* free */