From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5a9bede4d09438a9 X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: Re: Unbounded array Date: 1999/04/29 Message-ID: #1/1 X-Deja-AN: 472176503 References: <37247AA2.116F5E00@wbkst21.mach.uni-karlsruhe.de> <7g23a9$k3k$1@nnrp1.dejanews.com> <37262C39.D4F16DD8@wbkst21.mach.uni-karlsruhe.de> NNTP-Posting-Date: Wed, 28 Apr 1999 23:12:27 PDT Newsgroups: comp.lang.ada Date: 1999-04-29T00:00:00+00:00 List-Id: Pawel Kobylarz writes: > Realloc function takes two parameters, the actual pointer and new > size, and it preserves the data already present in the memory block. > Realloc is more efficient than allocate-copy-deallocate, because it > can add a piece of memory without moving existing data if there is > place after the existing block. But that isn't guaranteed. You save the cost of a copy only if there's an adjacent block large enough to contain the new part of the array. > In my textbook, I found only operators new and unchecked deallocation, > nothing similar to realloc(). Is there in ADA something like > realloc? No, it is not built in. However, you could 1) write a binding the C function 2) write your own storage pool that supports a realloc-style operation, and bind your access type to that pool; see RM95 13.11 There are open-source implementations of malloc, etc, so you should be able to use the algorithm to implement an Ada95 version.