4 ms·
Caller provided objects are a standard idiom that offers greater flexibility to use static/global vars, objects with a FAM, and custom allocators.
by kevin_thibedeau 5y ago
Caller provided objects are a standard idiom that offers greater flexibility to use static/global vars, objects with a FAM, and custom allocators.
- e12e 5y agoI was more thinking about the combination of caller provided object and callee returning a pointer (in this case to the same object). But I suppose it decouples "call time" resources from "return time" resources (the current api does not guarantee that the result will be in caller's "out", just that a buffer will be returned that the caller owns and have to de-allocate/manage).
- eqvinox 5y agoThat's a common (I wouldn't necessarily call it "standard") C idiom, to allow chaining calls. You could e.g. do puts(reverse(fwdbuf, reverse(revbuf, input)));