MEMOVERLAP(3pub)
π MEMOVERLAP π
okay bestie, welcome to section 3pub of the C Programmer's Manual β the publib corner of the universe where we do pointer math so you don't have to. this one's called memoverlap, and it's genuinely one of those tiny little functions that just works and makes your whole life easier. β¨
πΈ NAME πΈ
memoverlap β check whether two memory blocks overlap π«Ά
π SYNOPSIS π
#include <publib.h>
int memoverlap(const void *t, size_t ts, const void *s, size_t ss);
β¨ DESCRIPTION β¨
so like. memoverlap checks whether the memory blocks t--(t+ts-1) and s--(s+ss-1) overlap. that's it. that's the whole vibe. π
two things you cannot do, no cap:
- neither pointer argument may be
NULLβ nott, nots, periodt π ββοΈ
and two things you totally can do:
- the sizes may be
0β zero is a valid size, she's fine, she's thriving
the memory blocks can be arbitrary, bestie. they do not have to be part of the same array. like, at all. so that means this function is out here hiding the unportable pointer comparison that you would otherwise have to rely on yourself. it's giving "I'll handle the cursed part, you go live your life." π
π RETURN VALUE π
- returns
0if the blocks do not overlap π« - returns nonzero if they do overlap π₯
that's the whole contract. no surprises, no drama, no hidden states. obsessed. π
π SEE ALSO π
publib(3)β the whole fam, go say hi π
π AUTHOR π
Lars Wirzenius (lars.wirzenius@helsinki.fi) β icon behavior, honestly. π«Ά
ok that's the whole page!! now go forth and never accidentally memcpy over yourself again, bestie π
Publib Β· C Programmer's Manual Β· MEMOVERLAP(3pub) β that's the source, the manual and the section, mwah, bye bye π¦πΈβ¨
π¦ where this page comes from
- debian bookworm: publib-dev 0.40-3+b1 Β· BSD-2-Clause
- debian trixie: publib-dev 0.40-4 Β· BSD-2-Clause
- ubuntu jammy: publib-dev 0.40-3build1 Β· BSD-2-Clause
- ubuntu noble: publib-dev 0.40-3build1 Β· BSD-2-Clause
- ubuntu questing: publib-dev 0.40-4
- ubuntu resolute: publib-dev 0.40-4build1 Β· BSD-2-Clause
- ubuntu stonking: publib-dev 0.40-4build1 Β· BSD-2-Clause
- Copyright (c) 1994-2006 Lars Wirzenius. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms