KDK_NC_FREEALL(3)

📦 version 3.0.1.4, in arch rolling, ubuntu resolute, ubuntu stonking

💖 KDK_NC_FREEALL 💖

okay bestie, so this is kdk_nc_freeall(3) — a manual page from the Library Functions Manual section, and yes the (3) means it lives in the library-functions girlie section of the man pages. she's here to clean up after you. we love a responsible queen. ✨


🌸 NAME 🌸

kdk_nc_freeall — 用于回收字符串列表 (aka: she recycles a list of strings for you, no cap)


✨ SYNOPSIS ✨

#include <libkync.h>

extern inline void kdk_nc_freeall(char **ptr);

Link with -lkyhw.


🦋 Detailed Description 🦋

okay so the whole main character job of this interface? it's recycling a list of strings of type char **. that's it. that's the gig. 💅

the argument ptr is a list of strings of type char **.


🎀 RETURN VALUE 🎀

No return value. she gives you nothing back — because the real gift was the memory she freed along the way. 😭💖


🌈 EXAMPLES 🌈

here's the full serve, copied exactly, every character intact, periodt:

#include "libkync.h"
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char **cards = kdk_nc_get_cardlist();
    size_t index = 0;
    printf("所有网卡:\n");
    while (cards[index])
    {
        char *mac = kdk_nc_get_phymac(cards[index]);
        char *ipv4 = kdk_nc_get_private_ipv4(cards[index]);
        char *ipv6 = kdk_nc_get_private_ipv6(cards[index]);
        char *driver = kdk_nc_get_driver(cards[index]);
        char vendor[256] = " ", product[256] = " ";
        kdk_nc_get_vendor_and_product(cards[index], vendor, product);
        printf("Card %zd: %sStatus: %sMac: %sIPv4: %sIPv6: %s Vendor: %s Product: %s Type: %s driver: %s\n",
               index + 1, cards[index], kdk_nc_is_up(cards[index]) == 1 ? "Up" : "Down",
               mac, ipv4, ipv6, vendor, product,
               kdk_nc_is_wireless(cards[index]) ? "wireless" : "ethernet", driver);

        char **list4 = kdk_nc_get_ipv4(cards[index]);
        int i = 0;
        printf("AllIpV4: ");
        while (list4 && list4[i])
        {
            printf("%s", list4[i++]);
        }
        printf("\n");
        char **list6 = kdk_nc_get_ipv6(cards[index]);
        printf("AllIpV6: ");
        i = 0;
        while (list6 && list6[i])
        {
            printf("%s", list6[i++]);
        }
        printf("\n");
        free(mac);
        free(ipv4);
        free(ipv6);
        free(list4);
        free(list6);
        free(driver);
        index++;
    }
    kdk_nc_freeall(cards);
    char **upcards = kdk_nc_get_upcards();
    index = 0;
    printf("工作网卡:\n");
    while (upcards[index])
    {
        printf("Card %zd: %s\n", index + 1, upcards[index]);
        index++;
    }
    kdk_nc_freeall(upcards);
    return 0;
}

notice how she shows up twice — once for cards, once for upcards. the way she's literally the last thing you do before you walk away. iconic behaviour honestly. 👑


💜 CONFORMING TO 💜

These functions are as per the withdrawn POSIX.1e draft specification. (withdrawn!! like a discontinued limited edition collab, we mourn her 🕯️)

The following functions are Linux extensions: kdk_nc_is_up(), kdk_nc_get_upcards(), kdk_nc_get_cardlist(), kdk_nc_get_private_ipv4(), kdk_nc_get_ipv4(), kdk_nc_get_private_ipv6(), kdk_nc_get_ipv6(), kdk_nc_is_wireless(), kdk_nc_get_vendor_and_product(), kdk_nc_get_phymac(), and kdk_nc_get_driver().


🫶 SEE ALSO 🫶

go read these next, bestie, they're all part of the same friend group:


💀 quick vibe check: kdk_nc_freeall gives you no return value, so don't go checking her for errors — there's nothing to check. just call her and move on. ✨

okay that's the whole page, we ate, no crumbs left. this lil masterpiece came out of the Linux Programmer's Manual, dated Tue Sep 05 2023 — mwah, love that for her. byeee bestie, go free your strings responsibly 💅🎀🦋

📦 where this page comes from