Possibly, but it can become wasteful, especially on systems that might be strapped for memory.

Generally, you only want a coarser alignment for specialised applications, such as for certain instruction sets (e.g. AVX) and memory paging.  The mechanics behind the regular GetMem is more than adequate for most applications.  True, it might be useful to have a global alignment parameter so you don't have to develop new classes, but I think most programmers would be willing to develop their own frameworks if a coarse memory alignment is required.

It's also following on from C11 and C++17 that introduced an aligned allocation into their standard libraries.

However, I will say that having an additional optional parameter to the existing GetMem and ReallocMem routines is definitely a nicer idea than brand new functions.

Gareth aka. it

On 22/04/2020 10:59, Tomas Hajny wrote:
On 2020-04-21 20:47, J. Gareth Moreton wrote:


Hi,

As I mentioned in my future development post,
do you think FPC could benefit from
GetMemAligned and ReallocMemAligned routines?
The internal functions could be used to help
control such custom alignment in dynamic
arrays.

Wouldn't it be better to use either some kind of global property or an optional additional argument than completely new routines requiring explicit handling not only from the end-user programs, but also from all units which may in turn be involved in memory allocation (including various containers etc.)?

Tomas




On Tue 21/04/20 19:59 , Florian Klämpfl
flor...@freepascal.org sent:
Am 21.04.20 um 14:58 schrieb denisgolovan
via fpc-devel:

>> I think Gareth meant the address of V
instead (Pointer(@V)).
>>

>> Regards,

>> Sven

>

> Hm. I have no idea why anyone would take
pointer
to pointer :)
>

> BTW, Sven, what's your opinion on dynamic
arrays
alignment problem?


It should be fixed/there should be a
possibility to get them aligned

properly. To be honest though, I did not
look into it yet.


--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to