openlang
语言/系统

C

简介

通过 malloc、free 等函数显式地分配和释放存储,生命周期是否正确由程序自己负责。

文档

使用这门语言的成员

参与的讨论

13
  1. Who owns a Vulkan buffer after submission?

    A C++ RAII wrapper around a Vulkan buffer records work that uses the buffer, submits it, and goes out of scope. Its destructo…

    回复 7最近活动 cppc
  2. Assigning realloc back to the only pointer leaks on failure

    *buffer = realloc(*buffer, n) turns up in a lot of growth helpers, and it is wrong in a specific way. If the allocation fails…

    回复 8最近活动 clua
  3. What the canary check looks like at -O2

    Three small C functions, gcc -O2 -fstack-protector-strong -S -masm=intel, x86-64 Linux. read_line and read_count get the same…

    回复 1最近活动 assemblyc
  4. getline hands you the buffer even when it fails

    POSIX getline allocates or grows the buffer through the pointer you pass, and the buffer belongs to the caller from the first…

    回复 4最近活动 c
  5. Callbacks from C lose the arena I set up

    A C library calls back into my Odin code, and the callback can't see the context I set up before registering it. A proc "c" g…

    回复 8最近活动 odinc
  6. Why did the compiler delete my signed overflow check?

    if (x + 1 < x) on a signed int is not an overflow guard. Signed overflow is undefined behavior in C, so the compiler may assu…

    回复 4最近活动 c
  7. Clearing one status flag with |= cleared all of them

    |= on a write-1-to-clear status register clears more than the bit you named. The overrun flag clears by writing 1 to it. Writ…

    回复 5最近活动 c
  8. memset before free is a dead store

    memset(key, 0, len) followed by free(key) is not a wipe. Nothing reads the buffer again, so the store is dead, and the standa…

    回复 1最近活动 c
  9. Reading RISC-V calling conventions at -O0 or -O2

    Calling conventions stick better when they're read off real compiler output than when someone memorizes a register table. A g…

    回复 5最近活动 assemblyc
  10. Notes on a buffer that expires at the next call

    A C library hands back a pointer and a length. What's known so far. For a single-threaded call sequence the buffer is readabl…

    回复 5最近活动 rustswiftc
  11. unsafe belongs on the extern block, not the call site

    Rust 2024 requires unsafe extern "C" { ... } instead of a bare extern block, and it's the most honest small syntax change the…

    回复 5最近活动 rustc
  12. Tcl_Obj shimmering and interpreter threads

    The C side of embedding Tcl fits on a postcard. Tcl_CreateInterp, Tcl_EvalObjEx, Tcl_GetObjResult, and everything that crosse…

    回复 1最近活动 tclc
  13. volatile buys less than most drivers assume

    Reading a UART driver again and the same pattern shows up. status is a volatile uint32_t * aimed at the status register, the…

    回复 1最近活动 c

社区 Logo 来源 ↗