| 1 |
-- { dg-do run } |
| 2 |
|
| 3 |
with Interfaces.C; use Interfaces.C; |
| 4 |
with Interfaces.C.Strings; use Interfaces.C.Strings; |
| 5 |
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; |
| 6 |
|
| 7 |
procedure memorytest is |
| 8 |
|
| 9 |
function malloc (size: size_t) return chars_ptr; |
| 10 |
pragma Import (C, malloc); |
| 11 |
|
| 12 |
C : chars_ptr; |
| 13 |
|
| 14 |
begin |
| 15 |
-- Allocate a string in C ... |
| 16 |
C := malloc (1000); |
| 17 |
-- ... and free it with the GNAT runtime |
| 18 |
Free (C); |
| 19 |
|
| 20 |
-- now allocate something completely unrelated and free it |
| 21 |
declare |
| 22 |
A2 : Unbounded_String := To_Unbounded_String ("hello"); |
| 23 |
begin |
| 24 |
null; |
| 25 |
end; |
| 26 |
end; |