2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
7 #include <proto/exec.h>
9 /*****************************************************************************
12 #include <sys/types.h>
15 void * realloc_nocopy (
22 Change the size of an allocated part of memory. The memory must
23 have been allocated by malloc(), calloc(), realloc() or realloc_nocopy().
25 The reallocated buffer, unlike with realloc(), is not guaranteed to hold
26 a copy of the old one.
29 oldmen - What you got from malloc(), calloc(), realloc() or realloc_nocopy().
30 If NULL, the function will behave exactly like malloc().
31 size - The new size. If 0, the buffer will be freed.
34 A pointer to the allocated memory or NULL. If you don't need the
35 memory anymore, you can pass this pointer to free(). If you don't,
36 the memory will be freed for you when the application exits.
39 If you get NULL, the memory at oldmem will not have been freed and
42 This function must not be used in a shared library or
43 in a threaded application.
45 This function is AROS specific.
52 free(), malloc(), calloc(), realloc()
56 ******************************************************************************/
58 UBYTE
* mem
, * newmem
;
64 mem
= (UBYTE
*)oldmem
- AROS_ALIGN(sizeof(size_t));
65 oldsize
= *((size_t *)mem
);
67 /* Reduce or enlarge the memory ? */
70 /* Don't change anything for small changes */
71 if ((oldsize
- size
) < 4096)
76 else if (size
== oldsize
) /* Keep the size ? */
81 newmem
= malloc (size
);