2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
7 #include <proto/exec.h>
9 /*****************************************************************************
14 void * realloc_nocopy (
21 Change the size of an allocated part of memory. The memory must
22 have been allocated by malloc(), calloc(), realloc() or realloc_nocopy().
24 The reallocated buffer, unlike with realloc(), is not guaranteed to hold
25 a copy of the old one.
28 oldmem - What you got from malloc(), calloc(), realloc() or realloc_nocopy().
29 If NULL, the function will behave exactly like malloc().
30 size - The new size. If 0, the buffer will be freed.
33 A pointer to the allocated memory or NULL. If you don't need the
34 memory anymore, you can pass this pointer to free(). If you don't,
35 the memory will be freed for you when the application exits.
38 If you get NULL, the memory at oldmem will not have been freed and
41 This function is AROS specific.
48 free(), malloc(), calloc(), realloc()
52 ******************************************************************************/
54 UBYTE
* mem
, * newmem
;
60 mem
= (UBYTE
*)oldmem
- AROS_ALIGN(sizeof(size_t));
61 oldsize
= *((size_t *)mem
);
63 /* Reduce or enlarge the memory ? */
66 /* Don't change anything for small changes */
67 if ((oldsize
- size
) < 4096)
72 else if (size
== oldsize
) /* Keep the size ? */
77 newmem
= malloc (size
);