libwget-mem(3)

πŸ’– libwget-mem β€” Memory functions πŸ’–

okay bestie, so this is libwget-mem, from the libwget crew, and it's literally just a lil grab-bag of memory helpers. It's giving "the standard library forgot these so we wrote them ourselves." πŸŽ€


✨ SYNOPSIS ✨

🌸 Functions 🌸

void * wget_memdup (const void *m, size_t n)
char * wget_strdup (const char *s)
char * wget_strmemdup (const void *m, size_t n)
size_t wget_strmemcpy (char *s, size_t ssize, const void *m, size_t n)
void * wget_strmemcpy_a (char *s, size_t ssize, const void *m, size_t n)

πŸ¦‹ Detailed Description πŸ¦‹

This is a collection of short memory functions that are not available in the standard libraries. No cap, that's the whole vibe. πŸ’…


πŸ‘‘ Function Documentation πŸ‘‘

πŸ’œ void * wget_memdup (const void * m, size_t n)

Parameters

  • m β€” Memory to clone
  • n β€” Length of memory

Returns

  • Cloned memory

Clone's the memory region m with length n. Returns NULL if m is NULL.

bestie pls β€” you should free() the returned pointer when you don't need it any more. don't be that girl who leaks. 😭

πŸ’œ char * wget_strdup (const char * s)

Parameters

  • s β€” String to clone

Returns

  • Cloned string

Clone's the string s like strdup() does. Returns NULL if s is NULL.

same energy: free() the returned string when it's served its purpose. 🫢

πŸ’œ char * wget_strmemdup (const void * m, size_t n)

Parameters

  • m β€” Memory to convert into string
  • n β€” Length of memory

Returns

  • Created string

Convert the given memory region m with length n into a C string. Returns NULL if m is NULL.

and yes, once again: free() the returned string when you're done with it. the way that this family stays consistent πŸ’…

πŸ’œ size_t wget_strmemcpy (char * s, size_t ssize, const void * m, size_t n)

Parameters

  • s β€” Buffer to hold the C string output
  • ssize β€” Size of the output buffer
  • m β€” Memory to read from
  • n β€” Length of memory

Returns

  • Number of bytes copied, not counting the trailing 0 byte

Convert the given memory region m with length n into a C string at s. A max. of ssize - 1 is copied into s. lowkey important detail, don't sleep on it ⭐


πŸ’œ void * wget_strmemcpy_a (char * s, size_t ssize, const void * m, size_t n)

Parameters

  • s β€” Buffer to hold the C string output
  • ssize β€” Size of the output buffer
  • m β€” Memory to read from
  • n β€” Length of memory

Returns

  • Pointer to destination (either s or a freshly allocated buffer)

Convert the given memory region m with length n into a C string at s or at freshly allocated memory, if the space in s was not sufficient.

If s was too small to hold n + 1 bytes, the result must be free'd after use, like this:

if (res != s) wget_free(res);
🚨 bestie the vibe check here is REAL: if you skip that check you're leaking memory, and the leak is not cute. main character energy means cleaning up after yourself. periodt. πŸ”₯

🧚 Author 🧚

Generated automatically by Doxygen for wget2 from the source code. (not me writing my own wiki page, the robots did it πŸ’€)


okay that's the whole page, ily, go forth and clone memory responsibly πŸŒˆπŸ’–

✨ cute lil sign-off: this was libwget-mem(3) from wget2, Version 2.3.0 β€” bye bestie, drink water, free() your pointers πŸŽ€πŸ¦‹πŸ’œ
πŸ“¦ where this page comes from