🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

28 total messages Started by fir Sun, 29 Nov 2026 12:16
is wraper on realloc good idea? maybe more wrappers?
#1965
Author: fir
Date: Sun, 29 Nov 2026 12:16
2 lines
1308 bytes
never used it but generally wrappers on some standard functions
probably are good idea, or not?
Re: is wraper on realloc good idea? maybe more wrappers?
#1966
Author: fir
Date: Sun, 29 Nov 2026 14:57
14 lines
1813 bytes
fir pisze:
> never used it but generally wrappers on some standard functions
> probably are good idea, or not?

i also think if not tu built in system for localizing runtime errors

i rarely have runtime errors but when something appears its unplesant
the you need to do such weird debug thing to localize crash

sulution would be doing some simple list where i would log some
function tags in array in ram then probably i could show this is 
system/signal/crash handler i guess

i will see and probably will check it when having runtime cras next time
Re: is wraper on realloc good idea? maybe more wrappers?
#1967
Author: Ross Finlayson
Date: Sun, 29 Nov 2026 15:43
69 lines
4936 bytes
On 11/29/2026 06:57 AM, fir wrote:
> fir pisze:
>> never used it but generally wrappers on some standard functions
>> probably are good idea, or not?
>
> i also think if not tu built in system for localizing runtime errors
>
> i rarely have runtime errors but when something appears its unplesant
> the you need to do such weird debug thing to localize crash
>
> sulution would be doing some simple list where i would log some
> function tags in array in ram then probably i could show this is
> system/signal/crash handler i guess
>
> i will see and probably will check it when having runtime cras next time


In a sort of "C-minus" approach for "global-calls" or "glo-calls" above
"system-calls" or sys-calls", like I was just saying, there's an idea
to _hide_ syscalls via glocalls, that since when above "bare metal"
there's for example POSIX or the O.S. and processes & threads, where
a certain amount of discipline can always begin a process with
installing "glo-calls", then begin a thread with installing "glo-calls",
then with thread-local-storage making function pointers,
then that those are typed and for example live in a struct according
to types so the compiler can infer their types, then basically
that it adds a layer of functional indirection to each of those calls,
which some may aver would be wrong, yet then would be modular and
decomposable & recomposable, for composability, and modularity.

Kind of like syscalls are issued numbers then made signatures their
functional signatures, it's a similar idea for glocalls, except for
the process & thread, instead of the overall "globals" or system itself.



Then another thing fir scribbled the other day was unbalanced
parentheses, was "A { B { } /* closes A */ } /* closes B */ "
which is unbalanced when "A{ B{} }" is nested, about the state & scope
and a sort of "rock & roll" approach when re-using buffers, this
being about that in C: there's later the _defer_ keyword, which
indicates "the execution-graph will result in the flow-graph that
any of many possible exit-points visits the deferred statements
in LIFO order", and the call-stack in LIFO and call-sites in FIFO,
entry-sites and exit-sites or entry-points and exit-points, about
basically the "computed return value" which is a compiler extension
so that a function can know whether it's a first-descendent or
sibling or where it's at the location, about entry-points, since
there's no way to cover all the exit-points, without a lot of discipline
and redundancy in code, or changing the calling conventions.


I.e., the LIFO account of the call-stack and the linear contiguous
process/thread address space makes for lots of opportunities to use
arithmetic for the LIFO call-stack and FIFO call-sites, given that
there's not "goto" and that callee-functions always return to the
caller-function, about for example rocking & rolling re-used buffers
down through a bunch of property accessors and formatters, vis-a-vis
glo-calls about threads with small caches for re-used buffers,
then making for "location" as considered a sort of first-class
account for debugging, when basically that "locators" and "location",
like "source locators" or ye olde "FILE, LINE, ..." macros,
instead to just have locators according to the debug symbols so
that functions can just have a static variable that according to
the lifetime of the thread a thread-local variable for re-entrancy,
is about location and LIFO call-stack and FIFO call-site in all the code.


Re: is wraper on realloc good idea? maybe more wrappers?
#1968
Author: Ross Finlayson
Date: Sun, 29 Nov 2026 16:04
123 lines
7909 bytes
On 11/29/2026 07:43 AM, Ross Finlayson wrote:
> On 11/29/2026 06:57 AM, fir wrote:
>> fir pisze:
>>> never used it but generally wrappers on some standard functions
>>> probably are good idea, or not?
>>
>> i also think if not tu built in system for localizing runtime errors
>>
>> i rarely have runtime errors but when something appears its unplesant
>> the you need to do such weird debug thing to localize crash
>>
>> sulution would be doing some simple list where i would log some
>> function tags in array in ram then probably i could show this is
>> system/signal/crash handler i guess
>>
>> i will see and probably will check it when having runtime cras next time
>
>
> In a sort of "C-minus" approach for "global-calls" or "glo-calls" above
> "system-calls" or sys-calls", like I was just saying, there's an idea
> to _hide_ syscalls via glocalls, that since when above "bare metal"
> there's for example POSIX or the O.S. and processes & threads, where
> a certain amount of discipline can always begin a process with
> installing "glo-calls", then begin a thread with installing "glo-calls",
> then with thread-local-storage making function pointers,
> then that those are typed and for example live in a struct according
> to types so the compiler can infer their types, then basically
> that it adds a layer of functional indirection to each of those calls,
> which some may aver would be wrong, yet then would be modular and
> decomposable & recomposable, for composability, and modularity.
>
> Kind of like syscalls are issued numbers then made signatures their
> functional signatures, it's a similar idea for glocalls, except for
> the process & thread, instead of the overall "globals" or system itself.
>
>
>
> Then another thing fir scribbled the other day was unbalanced
> parentheses, was "A { B { } /* closes A */ } /* closes B */ "
> which is unbalanced when "A{ B{} }" is nested, about the state & scope
> and a sort of "rock & roll" approach when re-using buffers, this
> being about that in C: there's later the _defer_ keyword, which
> indicates "the execution-graph will result in the flow-graph that
> any of many possible exit-points visits the deferred statements
> in LIFO order", and the call-stack in LIFO and call-sites in FIFO,
> entry-sites and exit-sites or entry-points and exit-points, about
> basically the "computed return value" which is a compiler extension
> so that a function can know whether it's a first-descendent or
> sibling or where it's at the location, about entry-points, since
> there's no way to cover all the exit-points, without a lot of discipline
> and redundancy in code, or changing the calling conventions.
>
>
> I.e., the LIFO account of the call-stack and the linear contiguous
> process/thread address space makes for lots of opportunities to use
> arithmetic for the LIFO call-stack and FIFO call-sites, given that
> there's not "goto" and that callee-functions always return to the
> caller-function, about for example rocking & rolling re-used buffers
> down through a bunch of property accessors and formatters, vis-a-vis
> glo-calls about threads with small caches for re-used buffers,
> then making for "location" as considered a sort of first-class
> account for debugging, when basically that "locators" and "location",
> like "source locators" or ye olde "FILE, LINE, ..." macros,
> instead to just have locators according to the debug symbols so
> that functions can just have a static variable that according to
> the lifetime of the thread a thread-local variable for re-entrancy,
> is about location and LIFO call-stack and FIFO call-site in all the code.
>
>
>


Say for example that logging & metrics & tracing & debugging are
first-class concerns for any sort of program, they're cross-cutting
concerns like from "aspect-oriented programming", vis-a-vis ideas
like tear-offs and mixins and so on yet for AOP, here about
instrumentation, then for example leaving some NOPs in the code
so the debugger can always re-write its breakpoints into the code,
then particularly about the "locator", basically to make for that
there's only one tool the compiler (and its usual ecosystem of tools for
archive and link and libraries and the object file and sections what
result segments then for "debug symbols" or plainly "locator symbols"),
and it may generate or a build-step can generate what's
a reasonable section of the object file then that instead of ever
having FILE/LINE/FUNCTION macros sitting in the code, basically has
that the loader/linker can be made to do work and update the offsets
when the program starts, to install to what results a static in each
function its location, then for example about cross-cutting concerns
like logging & metrics & tracing & debugging, which often for example
should have _zero_ impact yet in the more verbose accounts become
increasingly instrumented/impactful, then is for an account of
making "location" a usual first-class cross-cutting account of
using the usual symbol files to result also program artifacts,
when for example it's to be transparent then for example that
the programming can be run with a sort of "otrace" or "ftrace"
output that sits inline with like "strace" or "ltrace", system
and library tracers, printing an entire result of the overall execution
graph.

Then accounts like logging & metrics basically for a "logmask and
metmask" can result that the locator results "logsite and metsite",
then for conditioning log-level and metrics-resolution at runtime,
with the usual idea of not even appearing to exist in the source
code except perhaps having a boilerplate line at the beginning of each
function of interest (others considered "inline").

Then, figuring out location/locator, for example making the
loader/linker do the work of "relocating the symbols",
may result those aspects behind an [un-likely] branch to
an indirect function pointer, type-safe and re-entrant as
it were, instead of "cluttering the code".

Idea being it would be the same and unobtrusive usually for
all programs, and yet work seamlessly and nicely with debuggers,
tracers, metrics-collectors, log-collectors, ..., as just another
common build-step, then with some minimum sorts conventions and
simplest sort of discipline, all without much inflating the code.


These are always usual "global" concerns.


Re: is wraper on realloc good idea? maybe more wrappers?
#1969
Author: Andrey Tarasevich
Date: Sun, 29 Nov 2026 16:09
17 lines
1976 bytes
On Sun 11/29/2026 4:16 AM, fir wrote:
> never used it but generally wrappers on some standard functions
> probably are good idea, or not?

In programs that perform non-interactive batch-style processing (e.g. 
config file on input, result file on output), error handling is usually 
a very simple affair: just complain and abort, no need for any kind of 
post-error recovery in most cases. In such programs wrappers around 
malloc/calloc/realloc work very well. The wrapper checks for success and 
simply aborts the entire program with an error message in case of 
failure. This allows client code to completely forget about having to 
worry about this sort of errors. I.e. it uses the wrapper under 
assumption that the wrapper "always succeeds".

-- 
Best regards,
Andrey
Re: is wraper on realloc good idea? maybe more wrappers?
#1971
Author: fir
Date: Sun, 29 Nov 2026 16:48
21 lines
2414 bytes
Andrey Tarasevich pisze:
> On Sun 11/29/2026 4:16 AM, fir wrote:
>> never used it but generally wrappers on some standard functions
>> probably are good idea, or not?
> 
> In programs that perform non-interactive batch-style processing (e.g. 
> config file on input, result file on output), error handling is usually 
> a very simple affair: just complain and abort, no need for any kind of 
> post-error recovery in most cases. In such programs wrappers around 
> malloc/calloc/realloc work very well. The wrapper checks for success and 
> simply aborts the entire program with an error message in case of 
> failure. This allows client code to completely forget about having to 
> worry about this sort of errors. I.e. it uses the wrapper under 
> assumption that the wrapper "always succeeds".
> 

but there is normal ERROR (the one that calls ERROR() function , more 
specifically ERROR_() in my case as ERROR is by some sht reserved by 
winapi i guess) and there are CRASHes..crashes you need to localize,
in winapi i may register signel handler so it calls my function that for 
example shows messagoe box ..
Re: is wraper on realloc good idea? maybe more wrappers?
#1972
Author: Ross Finlayson
Date: Sun, 29 Nov 2026 17:00
26 lines
2691 bytes
On 11/29/2026 08:48 AM, fir wrote:
> Andrey Tarasevich pisze:
>> On Sun 11/29/2026 4:16 AM, fir wrote:
>>> never used it but generally wrappers on some standard functions
>>> probably are good idea, or not?
>>
>> In programs that perform non-interactive batch-style processing (e.g.
>> config file on input, result file on output), error handling is
>> usually a very simple affair: just complain and abort, no need for any
>> kind of post-error recovery in most cases. In such programs wrappers
>> around malloc/calloc/realloc work very well. The wrapper checks for
>> success and simply aborts the entire program with an error message in
>> case of failure. This allows client code to completely forget about
>> having to worry about this sort of errors. I.e. it uses the wrapper
>> under assumption that the wrapper "always succeeds".
>>
>
> but there is normal ERROR (the one that calls ERROR() function , more
> specifically ERROR_() in my case as ERROR is by some sht reserved by
> winapi i guess) and there are CRASHes..crashes you need to localize,
> in winapi i may register signel handler so it calls my function that for
> example shows messagoe box ..

Does it build just fine on Navia's LCC or Mingw64?

Re: is wraper on realloc good idea? maybe more wrappers?
#1973
Author: fir
Date: Sun, 29 Nov 2026 17:26
29 lines
2806 bytes
Ross Finlayson pisze:
> On 11/29/2026 08:48 AM, fir wrote:
>> Andrey Tarasevich pisze:
>>> On Sun 11/29/2026 4:16 AM, fir wrote:
>>>> never used it but generally wrappers on some standard functions
>>>> probably are good idea, or not?
>>>
>>> In programs that perform non-interactive batch-style processing (e.g.
>>> config file on input, result file on output), error handling is
>>> usually a very simple affair: just complain and abort, no need for any
>>> kind of post-error recovery in most cases. In such programs wrappers
>>> around malloc/calloc/realloc work very well. The wrapper checks for
>>> success and simply aborts the entire program with an error message in
>>> case of failure. This allows client code to completely forget about
>>> having to worry about this sort of errors. I.e. it uses the wrapper
>>> under assumption that the wrapper "always succeeds".
>>>
>>
>> but there is normal ERROR (the one that calls ERROR() function , more
>> specifically ERROR_() in my case as ERROR is by some sht reserved by
>> winapi i guess) and there are CRASHes..crashes you need to localize,
>> in winapi i may register signel handler so it calls my function that for
>> example shows messagoe box ..
> 
> Does it build just fine on Navia's LCC or Mingw64?
> 
i use mingw32 and some older version as when i last checked (quite few 
years ago) the more new was slower..(and i prefer faster)
Re: is wraper on realloc good idea? maybe more wrappers?
#1978
Author: fir
Date: Sun, 29 Nov 2026 19:45
42 lines
3365 bytes
fir pisze:
> Ross Finlayson pisze:
>> On 11/29/2026 08:48 AM, fir wrote:
>>> Andrey Tarasevich pisze:
>>>> On Sun 11/29/2026 4:16 AM, fir wrote:
>>>>> never used it but generally wrappers on some standard functions
>>>>> probably are good idea, or not?
>>>>
>>>> In programs that perform non-interactive batch-style processing (e.g.
>>>> config file on input, result file on output), error handling is
>>>> usually a very simple affair: just complain and abort, no need for any
>>>> kind of post-error recovery in most cases. In such programs wrappers
>>>> around malloc/calloc/realloc work very well. The wrapper checks for
>>>> success and simply aborts the entire program with an error message in
>>>> case of failure. This allows client code to completely forget about
>>>> having to worry about this sort of errors. I.e. it uses the wrapper
>>>> under assumption that the wrapper "always succeeds".
>>>>
>>>
>>> but there is normal ERROR (the one that calls ERROR() function , more
>>> specifically ERROR_() in my case as ERROR is by some sht reserved by
>>> winapi i guess) and there are CRASHes..crashes you need to localize,
>>> in winapi i may register signel handler so it calls my function that for
>>> example shows messagoe box ..
>>
>> Does it build just fine on Navia's LCC or Mingw64?
>>
> i use mingw32 and some older version as when i last checked (quite few 
> years ago) the more new was slower..(and i prefer faster)
> 
more specifically i use tdm 5 and 10 (preferably 5)
i downloaded gcc 16 but it throws 150 fake errors in my face
(where i dont add void as i dont like etc)

this is so called populists takeover when they make freedom and error

(note my approach to programing is ratcher oposite, freedom is 
encouraged..as oldc also was - until populist jumped on t with their asses)

(more worse i dont see a switch to disable it and i no plan to sid and 
do thsi idiotic work adding that voids etc)
Re: is a wrapper on memory-allocation calls a good idea?
#1997
Author: Lawrence D’Oliveiro
Date: Mon, 30 Nov 2026 06:00
27 lines
2667 bytes
On Sun, 29 Nov 2026 08:09:16 -0800, Andrey Tarasevich wrote:

> In programs that perform non-interactive batch-style processing
> (e.g. config file on input, result file on output), error handling
> is usually a very simple affair: just complain and abort, no need
> for any kind of post-error recovery in most cases. In such programs
> wrappers around malloc/calloc/realloc work very well. The wrapper
> checks for success and simply aborts the entire program with an
> error message in case of failure. This allows client code to
> completely forget about having to worry about this sort of errors.
> I.e. it uses the wrapper under assumption that the wrapper "always
> succeeds".

You don’t even need a special wrapper to achieve that. On Linux
systems, you can set the memory-allocation policy to “overcommit”,
which basically means that, when a process asks for memory, the kernel
never says no <https://manpages.debian.org/proc_sys_vm(5)>.

So you don’t even need to bother to check for memory-allocation
failures, because you will never get a failure status. Instead,
if/when the system runs low on memory, a kernel thread known as “the
dreaded OOM killer” is loosed from the mythical underground cave where
it is normally kept chained, and it starts killing processes, starting
with the biggest memory hogs, until sanity, in the form of an adequate
memory reserve, is restored to the system.

In fact, this overcommit policy is usually the default setting.
Re: is a wrapper on memory-allocation calls a good idea?
#2000
Author: Bonita Montero
Date: Mon, 30 Nov 2026 06:16
21 lines
2421 bytes
Am 30.11.2026 um 07:00 schrieb Lawrence D’Oliveiro:

> You don’t even need a special wrapper to achieve that. On Linux
> systems, you can set the memory-allocation policy to “overcommit”,
> which basically means that, when a process asks for memory, the
> kernel never says no <https://manpages.debian.org/proc_sys_vm(5)>.
> 
> So you don’t even need to bother to check for memory-allocation
> failures, because you will never get a failure status. Instead,
> if/when the system runs low on memory, a kernel thread known as “the
> dreaded OOM killer” is loosed from the mythical underground cave where
> it is normally kept chained, and it starts killing processes, starting
> with the biggest memory hogs, until sanity, in the form of an adequate
> memory reserve, is restored to the system.
> 
> In fact, this overcommit policy is usually the default setting.

realloc() may be necessary nevertheless when a memory chunk isn't
large enough. With overcommit you could allocate more memory than
needed to reduce the likehood of realloc()s.
Re: is a wrapper on memory-allocation calls a good idea?
#2001
Author: Andrey Tarasevich
Date: Mon, 30 Nov 2026 06:44
17 lines
1922 bytes
On Sun 11/29/2026 10:00 PM, Lawrence D’Oliveiro wrote:
> So you don’t even need to bother to check for memory-allocation
> failures, because you will never get a failure status.

Well, firstly, overcommit approach simply substitutes "virtual address 
space" in place of "actual memory" as the limited resource. And while 
address space is usually huge, one can still exhaust it if one really 
sets their mind to it. This can still lead to an allocation failure.

Secondly, there's still the implementation-dependent limit for the 
largest continuous block in a single allocation, which can also lead to 
an allocation failure.

-- 
Best regards,
Andrey
Re: is a wrapper on memory-allocation calls a good idea?
#2016
Author: Dan Cross
Date: Mon, 30 Nov 2026 12:36
25 lines
2023 bytes
In article <11ej60c$6bhr$1@dont-email.me>,
Andrey Tarasevich  <noone@noone.net> wrote:
>On Sun 11/29/2026 10:00 PM, Lawrence D’Oliveiro wrote:
>> So you don’t even need to bother to check for memory-allocation
>> failures, because you will never get a failure status.
>
>Well, firstly, overcommit approach simply substitutes "virtual address
>space" in place of "actual memory" as the limited resource. And while
>address space is usually huge, one can still exhaust it if one really
>sets their mind to it. This can still lead to an allocation failure.
>[snip]

And even if we consider virtual memory near-infinite for
practical purposes, systems usually still impose an artifical
cap on it in the form of a configurable resource limit; this
is usually well-below the size of the virtual address space.

I am reminded of some of the programming advice common in the
after the introduction of virtual memory in Unix with the
adoption of the 32-bit VAX: "We've got a whole 4 Gigs!  No one
will ever use all of that, but you should still check the return
value of `malloc`."

	- Dan C.
Re: is a wrapper on memory-allocation calls a good idea?
#2017
Author: fir
Date: Mon, 30 Nov 2026 13:46
36 lines
3106 bytes
Dan Cross pisze:
> In article <11ej60c$6bhr$1@dont-email.me>,
> Andrey Tarasevich  <noone@noone.net> wrote:
>> On Sun 11/29/2026 10:00 PM, Lawrence D’Oliveiro wrote:
>>> So you don’t even need to bother to check for memory-allocation
>>> failures, because you will never get a failure status.
>>
>> Well, firstly, overcommit approach simply substitutes "virtual address
>> space" in place of "actual memory" as the limited resource. And while
>> address space is usually huge, one can still exhaust it if one really
>> sets their mind to it. This can still lead to an allocation failure.
>> [snip]
> 
> And even if we consider virtual memory near-infinite for
> practical purposes, systems usually still impose an artifical
> cap on it in the form of a configurable resource limit; this
> is usually well-below the size of the virtual address space.
> 
> I am reminded of some of the programming advice common in the
> after the introduction of virtual memory in Unix with the
> adoption of the 32-bit VAX: "We've got a whole 4 Gigs!  No one
> will ever use all of that, but you should still check the return
> value of `malloc`."
> 
> 	- Dan C.
> 
yesterday i got a crash related to reallock.. first time in my life
probbaly..it happend i wrote 1 slot after a reallocked memory and
it heppen 'sometimes' though rarely this 1 slot did overvritte
some of its metadata so sometimes - liek really rare something like
few thousand reallocks - i got a crash on reallock..thoug everything 
besides was ok.. so it took me over hour to find it...

i really rare dil with crashes (as i rarely use pointers though
in 'modern c' i would say (as i myself define it) i m a real heavu user 
of realloc
Re: is a wrapper on memory-allocation calls a good idea?
#2018
Author: fir
Date: Mon, 30 Nov 2026 13:48
43 lines
3289 bytes
fir pisze:
> Dan Cross pisze:
>> In article <11ej60c$6bhr$1@dont-email.me>,
>> Andrey Tarasevich  <noone@noone.net> wrote:
>>> On Sun 11/29/2026 10:00 PM, Lawrence D’Oliveiro wrote:
>>>> So you don’t even need to bother to check for memory-allocation
>>>> failures, because you will never get a failure status.
>>>
>>> Well, firstly, overcommit approach simply substitutes "virtual address
>>> space" in place of "actual memory" as the limited resource. And while
>>> address space is usually huge, one can still exhaust it if one really
>>> sets their mind to it. This can still lead to an allocation failure.
>>> [snip]
>>
>> And even if we consider virtual memory near-infinite for
>> practical purposes, systems usually still impose an artifical
>> cap on it in the form of a configurable resource limit; this
>> is usually well-below the size of the virtual address space.
>>
>> I am reminded of some of the programming advice common in the
>> after the introduction of virtual memory in Unix with the
>> adoption of the 32-bit VAX: "We've got a whole 4 Gigs!  No one
>> will ever use all of that, but you should still check the return
>> value of `malloc`."
>>
>>     - Dan C.
>>
> yesterday i got a crash related to reallock.. first time in my life
> probbaly..it happend i wrote 1 slot after a reallocked memory and
> it heppen 'sometimes' though rarely this 1 slot did overvritte
> some of its metadata so sometimes - liek really rare something like
> few thousand reallocks

maybe it was not even few thousends it was more like after 80x3000 
reallocks ;c

>- i got a crash on reallock..thoug everything 
> besides was ok.. so it took me over hour to find it...
> 
> i really rare dil with crashes (as i rarely use pointers though
> in 'modern c' i would say (as i myself define it) i m a real heavu user 
> of realloc
Re: is a wrapper on memory-allocation calls a good idea?
#2024
Author: Lawrence D’Oliveiro
Date: Mon, 30 Nov 2026 18:31
13 lines
1778 bytes
On Sun, 29 Nov 2026 22:44:26 -0800, Andrey Tarasevich wrote:

> On Sun 11/29/2026 10:00 PM, Lawrence D’Oliveiro wrote:
>>
>> On Linux systems, you can set the memory-allocation policy to
>> “overcommit”, which basically means that, when a process asks for
>> memory, the kernel never says no
>> <https://manpages.debian.org/proc_sys_vm(5)>.
>
> Well, firstly, overcommit approach simply substitutes "virtual
> address space" in place of "actual memory" as the limited resource.

No, it is actual memory that is being overcommitted.
Re: is a wrapper on memory-allocation calls a good idea?
#2025
Author: Lawrence D’Oliveiro
Date: Mon, 30 Nov 2026 18:34
19 lines
2076 bytes
On Mon, 30 Nov 2026 07:16:45 +0100, Bonita Montero wrote:

> Am 30.11.2026 um 07:00 schrieb Lawrence D’Oliveiro:
>
>> On Linux systems, you can set the memory-allocation policy to
>> “overcommit”, which basically means that, when a process asks for
>> memory, the kernel never says no
>> <https://manpages.debian.org/proc_sys_vm(5)>.
>
> realloc() may be necessary nevertheless when a memory chunk isn't
> large enough. With overcommit you could allocate more memory than
> needed to reduce the likehood of realloc()s.

Runtime memory allocators normally works in bigger units than
individual allocation requests, anyway. This is orthogonal to the
overcommit policy (or not) as supported by the kernel.

What the Linux policy option allows is you can simply forget to
check for out-of-memory errors.
Re: is a wrapper on memory-allocation calls a good idea?
#2029
Author: Ross Finlayson
Date: Mon, 30 Nov 2026 18:48
40 lines
3514 bytes
On 11/30/2026 10:31 AM, Lawrence D’Oliveiro wrote:
> On Sun, 29 Nov 2026 22:44:26 -0800, Andrey Tarasevich wrote:
>
>> On Sun 11/29/2026 10:00 PM, Lawrence D’Oliveiro wrote:
>>>
>>> On Linux systems, you can set the memory-allocation policy to
>>> “overcommit”, which basically means that, when a process asks for
>>> memory, the kernel never says no
>>> <https://manpages.debian.org/proc_sys_vm(5)>.
>>
>> Well, firstly, overcommit approach simply substitutes "virtual
>> address space" in place of "actual memory" as the limited resource.
>
> No, it is actual memory that is being overcommitted.
>


If a wrapper is considered a good idea, then here there's that when
there are many calls, for example in a loop, for example that need
buffers, and to prevent them having fixed-length or variable-length
array buffers in their code, when for the hot body or inner routine
it's called of the loop where the instructions are to fit in the
code-cache and the buffers are to fit in the data-cache, makes for
an idea of "rolling" the buffers in a sense, not to be confusing
shift & rotate, and "rocking" the buffers in a sense, since "rock &
roll" isn't already an idiom within programming itself though it's
after the rhythm & blues an account of the often the simple the tempo,
is basically for an account of, for example, a loop-body that in the
scope of the loop, manages memory with regards to "fixed-length buffers
large enough for any of the uses in the loop", this sort of account
of the "glo-calls" then the "fixed-length arrays: sized and aligned
to cache-line/memory-page/memory-huge-page", then for formatters
usually enough (eg, integer to string or string to integer, with
making a default representation then a localized representation then
an aligned representation as separate concerns, since the cache is hot,
makes for a model of a little machine in its own little body of
definition, "rock & roll rotating-buffers and formatting-layers".


Re: is a wrapper on memory-allocation calls a good idea?
#2032
Author: Ross Finlayson
Date: Mon, 30 Nov 2026 19:29
184 lines
10149 bytes
On 11/30/2026 10:48 AM, Ross Finlayson wrote:
> On 11/30/2026 10:31 AM, Lawrence D’Oliveiro wrote:
>> On Sun, 29 Nov 2026 22:44:26 -0800, Andrey Tarasevich wrote:
>>
>>> On Sun 11/29/2026 10:00 PM, Lawrence D’Oliveiro wrote:
>>>>
>>>> On Linux systems, you can set the memory-allocation policy to
>>>> “overcommit”, which basically means that, when a process asks for
>>>> memory, the kernel never says no
>>>> <https://manpages.debian.org/proc_sys_vm(5)>.
>>>
>>> Well, firstly, overcommit approach simply substitutes "virtual
>>> address space" in place of "actual memory" as the limited resource.
>>
>> No, it is actual memory that is being overcommitted.
>>
>
>
> If a wrapper is considered a good idea, then here there's that when
> there are many calls, for example in a loop, for example that need
> buffers, and to prevent them having fixed-length or variable-length
> array buffers in their code, when for the hot body or inner routine
> it's called of the loop where the instructions are to fit in the
> code-cache and the buffers are to fit in the data-cache, makes for
> an idea of "rolling" the buffers in a sense, not to be confusing
> shift & rotate, and "rocking" the buffers in a sense, since "rock &
> roll" isn't already an idiom within programming itself though it's
> after the rhythm & blues an account of the often the simple the tempo,
> is basically for an account of, for example, a loop-body that in the
> scope of the loop, manages memory with regards to "fixed-length buffers
> large enough for any of the uses in the loop", this sort of account
> of the "glo-calls" then the "fixed-length arrays: sized and aligned
> to cache-line/memory-page/memory-huge-page", then for formatters
> usually enough (eg, integer to string or string to integer, with
> making a default representation then a localized representation then
> an aligned representation as separate concerns, since the cache is hot,
> makes for a model of a little machine in its own little body of
> definition, "rock & roll rotating-buffers and formatting-layers".
>
>
>


About printf, the famous and sole facility in C, among the system
library or standard functions available to C according to C then POSIX,
has that it becomes its own little language and very terse then
employing the var-args, is quite flexible, yet in the same account,
rather rigid, which for example as for where gcc for quite some time,
and I'm not aware since when, provides errors when formatting specifiers
don't match the var-args type in the AST since then the
var-args would forget them and rigidly for example corrupt the stack
given wrong inputs, has that var-args is one of the worse boojums of
safety in C, then that formatting strings is often enough the second,
besides "off-by-one errors" which occur mostly anywhere due the 0-based
and 1-based and whether the "end" is beyond the "index", that everybody
knows and for example where -1 means "not-found" about size_t and
ssize_t "signed size_t", for examples.

So, implementing a "to_string" and "from_string" in C, or "to_str"
and "fro_str", can be broken out into layers of its considerations,
then for formatting and specifiers, like scale and precision and
padding and radix and so on, about the "format string" usually
enough "fmt", or "msgfmt", and, the variables to be interpolated
into the string, building those then of to_str/fro_str, or
tow_str/fro_str, currying those up quite broken out, so that then
the ideal of the alias/stall/branch/call/fault-less, can work on
rocking & rolling fixed length buffers, keeping the code fitting
in the code-cache and data fitting in the data-cache, in the
formatting-routine then the loop-body.

So, the idea here about the representations, or string-representations
or string-reps, is sort of like this: a stack of operations on a
representation to result representations, then, about when to ultimately
placeholder-substitute or interpolate those, into
something that looks like the bog-standard sort of use of "{myvar}"
for the expression in the substitution-placeholder, vis-a-vis,
print's formatters and friends.

int:
first needs radix to determine the alphabet,
might be negative so have a minus sign (or, an attribute)
would have attributes about for example the radix
then that's itself a sequence of digits,
decimal / hexadecimal / octal / binary
nobody uses radices other than that


float:
radix isn't relevant, it's decimal in the representation
might be "Not-a-Number"
it's signed, negative or non-negative
scale and precision / mantissa and significand
basically to be truncated to one of:
significant-digits of "scientific numbers"
fixed-length post-radix part (the radix means both the base and the
decimal point), counting beans usually

string:
it's already a string, ...

timespec / date-formats
this basically involves usually exactly only one of them,
then with many and various time-zones and date-formats
that being considered after though the "first rep" itself


Then, the idea is that what gets built of these, has all
the relevant attributes, to first return a string (or,
simply a struct containing the string and the attrs),
this "first rep", then the "second rep", is about "locale"
usually enough. So, that would involve date-formats and
so on, and data-formats, like for ISO646 usually here yet
for the "human-readable" gettings into accounts like locale
and commas and periods or commas and stops as they're called,
about modulus-separators (usually in groups of 3) and the radix-point
(here always a period/stop, "billiard" isn't a number here, though
it's a word in a language), then that the first rep has got what
can make an unambiguous second rep, particularly when for accounts
of usual data-formats, it's a no-op, and the first rep has a string,
then the second rep has things like "0x" for hexadecimal or "0" for
octal or "b" for binary for example besides things like as from the
original type, they're literals their suffixes when for example "L,
UL, LL, ULL, ...", common sorts representations.

Then, whether that sort of account of "literals" should precede
"localization", basically has that those are their own sort of
"locale", like "source" or "natural".


Then, later there's the padding & alignment, and alike for
leading zeros for example, or when for example "blank means
zero", about "empties & blanks & zero", when for example
to write something like "[NULL]" for what was null, that
suggests actually the earlier representation, then though
that padding & alignment seems live in the format, and about
that the format has to be parsed in a sense to have its expressions
indicate anything, then about that advising what formatters get involved.

int i = 1;
float f = 1.0f;
timespec ts = {0, 0};

printf("integer %d float %f seconds/subseconds %d/%d", i, f, ts);


prfmt("integer {} float {} seconds/subseconds {}/{}", fro_str(i),
fro_str(f), fro_str(ts));

Then, a usual idea would seem that fro_str doesn't return strings,
instead it returns a representation & formatting context, then
that prfmt, or if still using var-args, has they'd always be of a given
type, so that instead, it's just broken out each of those fixed length,
then with regards about how to overload functions according to
signature-length instead of otherwise a controlling-expression, whether
the compiler offers a built-in for parameter-count, and these kinds of
things.


So, then these varied accounts of representations their formatting,
get broken out into separate responsibilities, while being polymorphic,
in C, then being small and fitting in the code-cache, with their buffers
being reused (and not in the function body) so fitting in
the data-cache, then that what would seem "less efficient" compared
to "plain old printf & friends", isn't much different time-wise,
perhaps even faster for usual considerations where it's just
the same as "i_to_a" and "a_to_i", and getting those right including
validating (invalidating) the inputs is the same problem, and
much all there is to it.


"What if I want what only printf can do?": then make for
passing it a function pointer and buffer and and size and
have it can-do however you like, else that simply there's
only so many types and only so many formats then that
according to _type_ then the _Generic construct and __auto_type
can make it nicely overloaded then underloaded and hide all
the specific behind "prfmt" and "fro_str".






Re: is a wrapper on memory-allocation calls a good idea?
#2034
Author: Bonita Montero
Date: Mon, 30 Nov 2026 19:46
11 lines
1905 bytes
Am 30.11.2026 um 19:34 schrieb Lawrence D’Oliveiro:

> Runtime memory allocators normally works in bigger units than
> individual allocation requests, anyway. This is orthogonal to the
> overcommit policy (or not) as supported by the kernel.
> 
> What the Linux policy option allows is you can simply forget to
> check for out-of-memory errors.

Yes, because C doesn't have a proper memory exhaustion mechanism
like std::bad_alloc.
Re: is a wrapper on memory-allocation calls a good idea?
#2040
Author: Scott Lurndal
Date: Mon, 30 Nov 2026 21:10
23 lines
2098 bytes
Lawrence =?iso-8859-13?q?D=FFOliveiro?= <ldo@nz.invalid> writes:
>On Sun, 29 Nov 2026 22:44:26 -0800, Andrey Tarasevich wrote:
>
>> On Sun 11/29/2026 10:00 PM, Lawrence D’Oliveiro wrote:
>>>
>>> On Linux systems, you can set the memory-allocation policy to
>>> “overcommit”, which basically means that, when a process asks for
>>> memory, the kernel never says no
>>> <https://manpages.debian.org/proc_sys_vm(5)>.
>>
>> Well, firstly, overcommit approach simply substitutes "virtual
>> address space" in place of "actual memory" as the limited resource.
>
>No, it is actual memory that is being overcommitted.

That statement is completely orthogonal to Andrey's point, 
which stands.  The virtual address space is fundamentally
limited (40 to 64 bits generally speaking in modern CPUs),
which in turn limits the amount memory that a
process (or thread) can use at any one time.

Leaving aside POSIX resource limits, which can also be used
to limit resource usage by a process.
Re: is a wrapper on memory-allocation calls a good idea?
#2043
Author: Chris M. Thomasson
Date: Mon, 30 Nov 2026 23:16
14 lines
1977 bytes
On 11/30/2026 11:46 AM, Bonita Montero wrote:
> Am 30.11.2026 um 19:34 schrieb Lawrence D’Oliveiro:
> 
>> Runtime memory allocators normally works in bigger units than
>> individual allocation requests, anyway. This is orthogonal to the
>> overcommit policy (or not) as supported by the kernel.
>>
>> What the Linux policy option allows is you can simply forget to
>> check for out-of-memory errors.
> 
> Yes, because C doesn't have a proper memory exhaustion mechanism
> like std::bad_alloc.

Huh? Say malloc fails...
Re: is a wrapper on memory-allocation calls a good idea?
#2044
Author: Bonita Montero
Date: Tue, 01 Dec 2026 05:14
11 lines
1842 bytes
Am 01.12.2026 um 00:16 schrieb Chris M. Thomasson:

> On 11/30/2026 11:46 AM, Bonita Montero wrote:

>> Yes, because C doesn't have a proper memory exhaustion mechanism
>> like std::bad_alloc.

> Huh? Say malloc fails...

You don't seem to understand the difference between bad_alloc
and a null return value.
Re: is a wrapper on memory-allocation calls a good idea?
#2059
Author: Andrey Tarasevich
Date: Tue, 01 Dec 2026 15:51
27 lines
2382 bytes
On Mon 11/30/2026 10:31 AM, Lawrence D’Oliveiro wrote:
> On Sun, 29 Nov 2026 22:44:26 -0800, Andrey Tarasevich wrote:
> 
>> On Sun 11/29/2026 10:00 PM, Lawrence D’Oliveiro wrote:
>>>
>>> On Linux systems, you can set the memory-allocation policy to
>>> “overcommit”, which basically means that, when a process asks for
>>> memory, the kernel never says no
>>> <https://manpages.debian.org/proc_sys_vm(5)>.
>>
>> Well, firstly, overcommit approach simply substitutes "virtual
>> address space" in place of "actual memory" as the limited resource.
> 
> No, it is actual memory that is being overcommitted.

Yes, but the whole idea of "overcommiting" simply means that the 
allocator will _reserve_ virtual address space without checking whether 
there is physical storage to back it up.

Virtual address space of the process still needs to be reserved at the 
moment of allocation. And virtual address space still gets "used up" by 
such allocations. It can eventually run out. That is the point I was making.

-- 
Best regards,
Andrey
Re: is a wrapper on memory-allocation calls a good idea?
#2070
Author: Chris M. Thomasson
Date: Tue, 01 Dec 2026 20:44
14 lines
1951 bytes
On 11/30/2026 9:14 PM, Bonita Montero wrote:
> Am 01.12.2026 um 00:16 schrieb Chris M. Thomasson:
> 
>> On 11/30/2026 11:46 AM, Bonita Montero wrote:
> 
>>> Yes, because C doesn't have a proper memory exhaustion mechanism
>>> like std::bad_alloc.
> 
>> Huh? Say malloc fails...
> 
> You don't seem to understand the difference between bad_alloc
> and a null return value.

They both report something, no?
Re: is a wrapper on memory-allocation calls a good idea?
#2075
Author: Lowell Gilbert
Date: Tue, 01 Dec 2026 23:20
30 lines
2643 bytes
Andrey Tarasevich <noone@noone.net> writes:

> On Mon 11/30/2026 10:31 AM, Lawrence D’Oliveiro wrote:
>> On Sun, 29 Nov 2026 22:44:26 -0800, Andrey Tarasevich wrote:
>>> Well, firstly, overcommit approach simply substitutes "virtual
>>> address space" in place of "actual memory" as the limited resource.
>> No, it is actual memory that is being overcommitted.
>
> Yes, but the whole idea of "overcommiting" simply means that the
> allocator will _reserve_ virtual address space without checking
> whether there is physical storage to back it up.

and this happens because of the mechanics of (now POSIX) fork(), which
unfortunately was built into the fundament decades ago (long before
POSIX)

> Virtual address space of the process still needs to be reserved at the
> moment of allocation. And virtual address space still gets "used up"
> by such allocations. It can eventually run out. That is the point I
> was making.

In theory, yes. But if it became (even foreseeably) a problem, we would
probably build systems with larger address spaces, in which case
"properly written" (ahem) C code would automatically use the larger
space without any problem. This has, obviously, happened before.

Be well.
-- 
Lowell Gilbert, embedded/networking software engineer
	 http://be-well.ilk.org/~lowell/
Re: is a wrapper on memory-allocation calls a good idea?
#2076
Author: Kaz Kylheku
Date: Wed, 02 Dec 2026 00:33
51 lines
3736 bytes
On 2026-12-01, Lowell Gilbert <lgusenet@be-well.ilk.org> wrote:
> Andrey Tarasevich <noone@noone.net> writes:
>
>> On Mon 11/30/2026 10:31 AM, Lawrence D’Oliveiro wrote:
>>> On Sun, 29 Nov 2026 22:44:26 -0800, Andrey Tarasevich wrote:
>>>> Well, firstly, overcommit approach simply substitutes "virtual
>>>> address space" in place of "actual memory" as the limited resource.
>>> No, it is actual memory that is being overcommitted.
>>
>> Yes, but the whole idea of "overcommiting" simply means that the
>> allocator will _reserve_ virtual address space without checking
>> whether there is physical storage to back it up.
>
> and this happens because of the mechanics of (now POSIX) fork(), which
> unfortunately was built into the fundament decades ago (long before
> POSIX)

It's completely unrelated to fork. A virtual allocator reserves
regions of virtual memory, which become unavailable to other
allocations in that same address space.

Since it is possible (and common) for a system to give each process
its own virtual address space, a virtual allocation only makes
something unavailable to the same process; it doesn't reserve
virtual space in such a way that it is not available to another process.

A virtual allocation does require some global resources other than just
abstract space. The allocation has to be tracked somewhere (e.g.
tree structure like struct vm_area in Linux) and it is installed
into the page directory/tables of the process, which requires some
amount of memory (much smaller than what the virtual space would
occupy when fully populated by frames, but much larger than the zero
storage that totally uncommitted virtual space occupies).

The discipline by which new processes are created (fork, posix_spawn,
CreateProcess, ...) interacts with virtual memory but has no bearing on
the above basics.

It's possible to have a virtual memory system which has only one
address space. Some "DOS extenders" in the late 1980s and 1990s
were like this.

In effect, also, the Linux kernel is like this w.r.t. its own kernel
space virtual allocator, vmalloc. The virtual memory area
carved out by vmalloc is global inside the kernel; it doesn't switch
with the current running task.

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
Re: is a wrapper on memory-allocation calls a good idea?
#2079
Author: Bonita Montero
Date: Wed, 02 Dec 2026 04:18
6 lines
1788 bytes
Am 01.12.2026 um 21:44 schrieb Chris M. Thomasson:

> They both report something, no?

The kind of error handling is completely different.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads