Skip to content

Commit c0068df

Browse files
committed
Merge branch 'wip/doc-memory' into 'master'
Update instructions explaining the use of GNATcoll.Memory See merge request eng/toolchain/gnatcoll-core!34
2 parents 4424323 + 66cbb4b commit c0068df

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

docs/memory.rst

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ the standard malloc and free system calls. However, it calls those through
1010
an Ada proxy, in the package `System.Memory` that you can also
1111
replace in your own application if need be.
1212

13-
Like this::
14-
15-
procedure Ada
16-
1713
`gnatcoll` provides such a possible replacement. Its implementation
1814
is also based on `malloc` and `free`, but if you so chose you
1915
can activate extra monitoring capabilities to help you find out which parts
@@ -46,11 +42,31 @@ preparation in your application:
4642
begin
4743
return M.Realloc (Ptr, M.size_t (Size));
4844
end Realloc;
49-
end;
45+
end System.Memory;
46+
47+
* You then need to compile your application so it incorporates the
48+
alternative implementation, through the following steps for example:
49+
50+
#. Create a subdir, say "custom_rts" where you will put the alternative
51+
version of s-memory.adb,
52+
53+
#. Create a custom_rts.gpr project file with this contents
54+
55+
.. code-block::
56+
57+
with "gnatcoll.gpr";
58+
project Custom_Rts is
59+
for Source_Dirs use (Project'Name);
60+
for Object_Dir use "obj-" & Project'Name;
61+
62+
package Compiler is
63+
for Switches ("Ada") use ("-gnatg");
64+
end Compiler;
65+
end Custom_Rts;
5066
51-
* You then need to compile your application with the extra switch
52-
`-a` passed to `gnatmake` or `gprbuild`, so that this
53-
file is appropriately compiled and linked with your application
67+
#. Add a `with "custom_rts.gpr";` clause to your main project
68+
file and a `with System.Memory;` clause to one of the units in
69+
you program closure.
5470

5571
* If you only do this, the monitor is disabled by default. This
5672
basically has zero overhead for your application (apart from the initial

0 commit comments

Comments
 (0)