MEMFILL(3pub)
π MEMFILL β the manual page, but make it bestie π
okay so this is memfill, a lil function from the Publib collection, and it lives in section 3pub of the C Programmer's Manual. she fills up memory with a pattern. that's it. that's the whole vibe. and honestly? iconic. β¨
πΈ NAME πΈ
memfill β fill a memory area with a pattern π
β¨ SYNOPSIS β¨
#include <publib.h>
void *memfill(void *buf, size_t size, const void *pat, size_t patsize);
π¦ DESCRIPTION π¦
so here's the tea, bestie π β memfill copies consecutive bytes from the pattern pat straight into consecutive bytes of the memory area buf.
and when it runs out of pattern? it does NOT give up, she just wraps around back to the start of pat and keeps going. main character energy fr fr π
patsizeis the size of the pattern β like, how long the pattern issizeis the size of the memory area β like, how much space you're filling up
π¨ IMPORTANT CAVEAT, NO CAP: the pattern and the memory area must not be overlapping. like, not even a little. do not do it. i'm literally begging π
π RETURN VALUE π
memfill returns its first argument. that's it. she gives you back what you gave her. reciprocal queen π«Ά
π EXAMPLE π
ok so say you wanna initialize an integer array β this is the move right here:
int temp, array[1024];
temp = 1234;
memfill(array, sizeof(array), &temp, sizeof(temp));
look at that. temp is the pattern, array gets filled, sizes handled with sizeof. slay. no notes. π
β¨
π SEE ALSO π
publib(3)β the whole Publib family, go say hi π
π AUTHOR π
Lars Wirzenius (lars.wirzenius@helsinki.fi) β the legend who wrote this. we stan. π
and that's the whole page bestie!! this absolute banger comes to you from Publib, documented in the C Programmer's Manual, filed under MEMFILL(3pub) β mwah, go forth and fill some memory ππ§πΈ
π¦ 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