4.115
Last change
on this file since 98b785e was
7c658fe,
checked in by Joel Sherrill <joel.sherrill@…>, on 06/30/10 at 15:36:48
|
2010-06-30 Joel Sherrill <joel.sherrilL@…>
PR 1472/cpukit
- libcsupport/Makefile.am, libcsupport/include/rtems/malloc.h,
libcsupport/src/free.c, libcsupport/src/malloc.c,
libcsupport/src/malloc_initialize.c, libcsupport/src/realloc.c,
libcsupport/src/rtems_memalign.c: Remove malloc boundary code. It has
not been used since before 4.6 and is bitrotted.
- libcsupport/src/malloc_boundary.c: Removed.
|
-
Property mode set to
100644
|
File size:
1.6 KB
|
Line | |
---|
1 | /* |
---|
2 | * calloc() |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-2007. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * The license and distribution terms for this file may be |
---|
8 | * found in the file LICENSE in this distribution or at |
---|
9 | * http://www.rtems.com/license/LICENSE. |
---|
10 | * |
---|
11 | * $Id$ |
---|
12 | */ |
---|
13 | |
---|
14 | #if HAVE_CONFIG_H |
---|
15 | #include "config.h" |
---|
16 | #endif |
---|
17 | |
---|
18 | #ifdef RTEMS_NEWLIB |
---|
19 | #include "malloc_p.h" |
---|
20 | #include <stdlib.h> |
---|
21 | #include <errno.h> |
---|
22 | |
---|
23 | void *realloc( |
---|
24 | void *ptr, |
---|
25 | size_t size |
---|
26 | ) |
---|
27 | { |
---|
28 | uintptr_t old_size; |
---|
29 | char *new_area; |
---|
30 | |
---|
31 | MSBUMP(realloc_calls, 1); |
---|
32 | |
---|
33 | /* |
---|
34 | * Do not attempt to allocate memory if in a critical section or ISR. |
---|
35 | */ |
---|
36 | |
---|
37 | if (_System_state_Is_up(_System_state_Get())) { |
---|
38 | if (_Thread_Dispatch_disable_level > 0) |
---|
39 | return (void *) 0; |
---|
40 | |
---|
41 | if (_ISR_Nest_level > 0) |
---|
42 | return (void *) 0; |
---|
43 | } |
---|
44 | |
---|
45 | /* |
---|
46 | * Continue with realloc(). |
---|
47 | */ |
---|
48 | if ( !ptr ) |
---|
49 | return malloc( size ); |
---|
50 | |
---|
51 | if ( !size ) { |
---|
52 | free( ptr ); |
---|
53 | return (void *) 0; |
---|
54 | } |
---|
55 | |
---|
56 | if ( !_Protected_heap_Get_block_size(RTEMS_Malloc_Heap, ptr, &old_size) ) { |
---|
57 | errno = EINVAL; |
---|
58 | return (void *) 0; |
---|
59 | } |
---|
60 | |
---|
61 | /* |
---|
62 | * Now resize it. |
---|
63 | */ |
---|
64 | if ( _Protected_heap_Resize_block( RTEMS_Malloc_Heap, ptr, size ) ) { |
---|
65 | return ptr; |
---|
66 | } |
---|
67 | |
---|
68 | /* |
---|
69 | * There used to be a free on this error case but it is wrong to |
---|
70 | * free the memory per OpenGroup Single UNIX Specification V2 |
---|
71 | * and the C Standard. |
---|
72 | */ |
---|
73 | |
---|
74 | new_area = malloc( size ); |
---|
75 | |
---|
76 | MSBUMP(malloc_calls, (uint32_t) -1); /* subtract off the malloc */ |
---|
77 | |
---|
78 | if ( !new_area ) { |
---|
79 | return (void *) 0; |
---|
80 | } |
---|
81 | |
---|
82 | memcpy( new_area, ptr, (size < old_size) ? size : old_size ); |
---|
83 | free( ptr ); |
---|
84 | |
---|
85 | return new_area; |
---|
86 | |
---|
87 | } |
---|
88 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.