-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit a6678e3
Hook realloc for test harness
This commit implements test_realloc to support dynamic adjustment
of memory sizes allocated by test_malloc or test_calloc.
In this commit, when shrinking an allocated block (e.g., from 100 bytes
to 10), memory corruption beyond the new size (such as m[i] for
10 <= i <= 99) cannot be detected. This limitation stems from
the fact that the original memory block is retained after shrinking.
While this approach helps avoid unnecessary memory copies, especially
in cases where memory is often expanded and reduced, it can leave
unused memory behind. Although this may improve performance when
memory is plentiful, it may also lead to wasted space.
There is still room for improvement in future versions to better
manage memory use and detect corruption when shrinking blocks.
Change-Id: Iebf68ea810c73549d966cb2305a5470863dacde51 parent 9563d40 commit a6678e3
2 files changed
+27
-1
lines changedLines changed: 25 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
63 | 63 |
| |
64 | 64 |
| |
65 | 65 |
| |
66 | + | ||
66 | 67 |
| |
67 | 68 |
| |
68 | 69 |
| |
| |||
128 | 129 |
| |
129 | 130 |
| |
130 | 131 |
| |
132 | + | ||
131 | 133 |
| |
132 | 134 |
| |
133 | 135 |
| |
| |||
137 | 139 |
| |
138 | 140 |
| |
139 | 141 |
| |
142 | + | ||
140 | 143 |
| |
141 | 144 |
| |
142 | 145 |
| |
| |||
187 | 190 |
| |
188 | 191 |
| |
189 | 192 |
| |
193 | + | ||
194 | + | ||
195 | + | ||
196 | + | ||
197 | + | ||
198 | + | ||
199 | + | ||
200 | + | ||
201 | + | ||
202 | + | ||
203 | + | ||
204 | + | ||
205 | + | ||
206 | + | ||
207 | + | ||
208 | + | ||
209 | + | ||
210 | + | ||
211 | + | ||
212 | + | ||
213 | + | ||
214 | + | ||
190 | 215 |
| |
191 | 216 |
| |
192 | 217 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
15 | + | ||
15 | 16 |
| |
16 | 17 |
| |
17 | - | ||
18 | 18 |
| |
19 | 19 |
| |
20 | 20 |
| |
| |||
56 | 56 |
| |
57 | 57 |
| |
58 | 58 |
| |
59 | + | ||
59 | 60 |
| |
60 | 61 |
| |
61 | 62 |
| |
|
0 commit comments