KDK_HW_FREE_PCI_INFO(3)

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

💅 KDK_HW_FREE_PCI_INFO(3) — ok so hear me out bestie 💅

Hii so you're looking at the KDK_HW_FREE_PCI_INFO(3) page, from the Library Functions Manual. It's giving "one tiny little function that does one tiny little job and does it flawlessly" energy and honestly? We love that for it. It's the cleanup crew for your PCI info. No cap. ✨


✨ NAME ✨

kdk_hw_free_pci_info — 释放由 kdk_hw_get_pci_info 返回的 pci 总线信息结构体

Okay so translating the vibe: this is the girl whose entire job is freeing the PCI bus info struct that kdk_hw_get_pci_info handed you. You got the struct, you did your little printf tour of it, now you hand it back. Closure. Literally. 🎀


🌸 SYNOPSIS 🌸

#include <libkysysinfo.h>

extern void kdk_hw_free_pci_info(struct KPci *info);

Link with -lkysysinfo.

So like — include the header, call the thing, and when you compile, don't forget the -lkysysinfo flag or the linker is gonna be so dramatic about it. 😭


🔍 DETAILED DESCRIPTION 🔍

The main function of the interface is to release the pci bus information structure returned by the kdk_hw_get_pci_info.

The argument info is the return value of the kdk_hw_get_pci_info.

So real talk, that's the whole plot: kdk_hw_get_pci_info gives you a struct, and this function takes it back. And the thing you pass as info is literally the return value you got from kdk_hw_get_pci_info. Not a copy, not a cousin of it, not "something that looks like it" — the actual thing it gave you. Matching set, periodt. 👑


🫶 RETURN VALUE 🫶

No return value.

Yeah she returns void. She gives you nothing back except peace of mind and reclaimed memory. That's the whole flex. 💖


🦋 EXAMPLES 🦋

Okay here's the full demo program. There's a LOT going on in here — she's printing basically every system fact that exists, and then right in the middle she grabs the PCI info with kdk_hw_get_pci_info(), walks the linked list with tmp = tmp->next, prints all the juicy fields, and finally hits kdk_hw_free_pci_info(pci); to clean up. Chef's kiss. Note that the // free(res); after kdk_system_get_eUser() is commented out and the cloud platform type bit is commented out too — I'm not touching anything, I'm showing you exactly what's there, bestie. 🙈

#include <libkysysinfo.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char *res = kdk_system_get_architecture();
    printf("架构:%s0, res);
    free(res);
    res = kdk_system_get_systemName();
    printf("系统名称:%s0, res);
    free(res);
    res = kdk_system_get_version(0);
    printf("系统简略版本:%s0, res);
    free(res);
    res = kdk_system_get_version(1);
    printf("系统详细版本:%s0, res);
    free(res);
    res = kdk_system_get_kernelVersion();
    printf("内核版本:%s0, res);
    free(res);
    res = kdk_system_get_serialNumber();
    printf("序列号:%s0, res);
    free(res);
    int p;
    int d;
    int act = kdk_system_get_activationStatus(&p,&d);
    printf("--------------0);
    printf("激活状态码:%d0,act);
    printf("激活状态:%s0, act == 1 ? "已激活" : act == 0 ? "未激活" : "已过期");

    res = kdk_system_get_eUser();
    printf("当前用户:%s0, res);
    // free(res);

    res = kdk_system_get_eUser_login_time();
    printf("登录时间:%s0, res);

    res = kdk_system_get_projectName();
    printf("项目编号名:%s0, res);
    free(res);
    int zyj = kdk_system_is_zyj();
    printf("专用机:%s0, zyj == 0 ? "非专用机":"专用机");

    res = kdk_system_get_hostVirtType();
    printf("虚拟机类型:%s0, res);
    free(res);

    res = kdk_system_get_hostCloudPlatform();
    printf("云平台类型:%s0, res);
    free(res);

    version_t test = kdk_system_get_version_detaile( );
    printf("test.os_version = %s0,test.os_version);
    printf("test.update_version = %s0,test.update_version);

    char** name = kdk_system_get_resolving_power();
    // printf("name = %s0, name);
    size_t count = 0;
    while (name[count])
    {
        printf("No. %d %s0, count + 1, name[count]);
        count ++;
    }
    kdk_resolving_freeall(name);

    char *ver = kdk_system_get_systemCategory();
    printf("系统硬件版本类别 = %s0, ver);
    free(ver);

    // ver = kdk_system_get_cloudPlatformType();
    // printf("云平台类型 = %s0, ver);
    // free(ver);

    char **ud_time = kdk_system_get_startup_time();
    count = 0;
    while (ud_time[count])
    {
        printf("开机时间 = %s0, ud_time[count]);
        count++;
    }
    kdk_resolving_freeall(ud_time);

    ud_time = kdk_system_get_shutdown_time();
    count = 0;
    while (ud_time[count])
    {
        printf("关机时间 = %s0, ud_time[count]);
        count++;
    }
    kdk_resolving_freeall(ud_time);

    res = kdk_get_host_vendor();
    printf("整机制造商 = %s0, res);
    free(res);

    res = kdk_get_host_product();
    printf("整机型号 = %s0, res);
    free(res);

    res = kdk_get_host_serial();
    printf("整机序列号 = %s0, res);
    free(res);

    res = kdk_system_get_buildTime();
    printf("构建时间:%s0, res);
    free(res);

    res = kdk_system_get_hostName();
    printf("主机名:%s0, res);
    free(res);

    printf("系统位数:%d0, kdk_system_get_word());

    struct KPci *pci = kdk_hw_get_pci_info();
    struct KPci *tmp = pci;
    while (tmp)
    {
        printf("slot path : %s0, tmp->slot_path);
        printf("class name :%s0, tmp->class_name);
        printf("product name :%s0, tmp->product_name);
        printf("rev :%02x0, tmp->rev);
        printf("subsystem name :%s0, tmp->ss_name);
        printf("driver user :%s0, tmp->driver_use);
        printf("modules :");
        for(int i = 0; i < tmp->module_count; i++)
        {
            printf("%s", tmp->modules[i]);
        }
        printf("0);
        tmp = tmp->next;
    }
    kdk_hw_free_pci_info(pci);

    res = kdk_system_get_appScene();
    printf("应用场景:%s0, res);
    free(res);

    return 0;
}
Quick lil heads-up bestie: the code above is reproduced exactly as it appears in the original page — every %s0, every printf("--------------0);, every commented-out free(res), all of it. I am not editing a single character, that's not my job, my job is ✨vibes✨. Copy it verbatim if you copy it at all. 💀

👑 CONFORMING TO 👑

These functions are as per the withdrawn POSIX.1e draft specification.

The following functions are Linux extensions:

  • kdk_system_get_systemName()
  • kdk_system_get_architecture()
  • kdk_system_get_activationStatus()
  • kdk_system_get_version()
  • kdk_system_get_serialNumber()
  • kdk_system_get_kernelVersion()
  • kdk_system_get_eUser()
  • kdk_system_get_eUser_login_time()
  • kdk_system_get_projectName()
  • kdk_system_get_projectSubName()
  • kdk_system_get_productFeatures()
  • kdk_system_get_hostVirtType()
  • kdk_system_get_hostCloudPlatform()
  • kdk_system_is_zyj()
  • kdk_system_get_version_detaile()
  • kdk_system_get_resolving_power()
  • kdk_system_get_systemCategory()
  • kdk_system_get_startup_time()
  • kdk_system_get_shutdown_time()
  • kdk_get_host_vendor()
  • kdk_get_host_product()
  • kdk_get_host_serial()
  • kdk_system_get_hostName()
  • kdk_system_get_word()
  • kdk_system_get_buildTime()
  • kdk_resolving_freeall()
  • kdk_hw_get_pci_info()
  • kdk_system_get_appScene()

So the POSIX.1e draft spec is withdrawn, which is giving "we tried, it didn't work out, but the lore remains" — and then everything in that list up there is a Linux extension. Both facts, both true, both staying. 🌈


💜 SEE ALSO 💜

Go read her sisters, they're all iconic in their own way:


And that's the page, bestie!! 🫶 This whole thing lives in the Linux Programmer's Manual and it's dated Tue Sep 19 2023 — shoutout to that exact Tuesday, she came through with the docs. Free your PCI structs, stay hydrated, and never forget kdk_hw_free_pci_info(pci); at the end. Mwah. 💖✨🎀🦋

📦 where this page comes from