MEMINS(3pub)
π MEMINS(3pub) β the publib glow-up edition β¨
okay bestie, welcome to the C Programmer's Manual, publib chapter, and today's main character is memins π
she's a memory-block girly and she EATS.
πΈ NAME πΈ
memins β insert bytes at the beginning of a memory block π«Ά
β¨ SYNOPSIS β¨
#include <publib.h>
void *memins(void *tgt, size_t tgtsize, const void *src, size_t srcsize);
like. that's the whole vibe. one function, four args, no notes π
π DESCRIPTION π
so here's the tea β memins takes srcsize bytes from src and inserts them at the beginning of tgt β but bestie, she's polite about it, she moves the first tgtsize bytes out of the way to make room π
β οΈ and this is the part where you LISTEN: the source and target memory blocks must not overlap. fr fr. no cap. overlapping them is not it π
π RETURN VALUE π
memins returns its first argument. that's it. that's the whole return. she gives you back tgt like "here u go queen π"
π¦ EXAMPLE π¦
say you wanna insert a new element at the ith position of an array β iconic behavior, very demure. you'd do this:
int new, array[10];
memins(array+i, (10-i-1)*sizeof(array[0]), &new, sizeof(new));
and pls pls PLS notice π that the code above carefully avoids the trap of moving the last element of the array past the end of the array. like, that's the whole reason for the (10-i-1) math bestie, don't skip it, it's giving attention to detail π
β¨
π SEE ALSO π
β AUTHOR β
Lars Wirzenius (lars.wirzenius@helsinki.fi) β the legend, the blueprint, the moment π
okay that's the whole page, love u, go forth and insert responsibly π«Άπ this was publib's C Programmer's Manual, page MEMINS(3pub), brought to you by the publib girlies β¨ bye bestie!! ππ¦
π¦ 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