GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Conversation

Notices

  1. Embed this notice
    Leah Rowe is not a Rowebot (libreleah@mas.to)'s status on Sunday, 22-Mar-2026 20:34:36 JST Leah Rowe is not a Rowebot Leah Rowe is not a Rowebot

    /* SPDX-License-Identifier: MIT */

    int
    scmp(const char *a,
    const char *b,
    size_t maxlen,
    int *rval)
    {
    size_t ch;
    unsigned char ac;
    unsigned char bc;

    if (a == NULL ||
    b == NULL ||
    rval == NULL) {

    errno = EFAULT;
    return -1;
    }

    for (ch = 0; ch < maxlen; ch++) {

    ac = (unsigned char)a[ch];
    bc = (unsigned char)b[ch];

    if (ac != bc) {
    *rval = ac - bc;
    return 0;
    }

    if (ac == '\0') {
    *rval = 0;
    return 0;
    }
    }

    errno = EFAULT;
    return -1;
    }

    In conversation about 17 days ago from mas.to permalink
    • Embed this notice
      Leah Rowe is not a Rowebot (libreleah@mas.to)'s status on Sunday, 22-Mar-2026 20:36:35 JST Leah Rowe is not a Rowebot Leah Rowe is not a Rowebot
      in reply to

      /* SPDX-License-Identifier: MIT */

      int
      slen(const char *s,
      size_t maxlen,
      size_t *rval)
      {
      size_t ch;

      if (s == NULL ||
      rval == NULL) {

      errno = EFAULT;
      return -1;
      }

      for (ch = 0;
      ch < maxlen && s[ch] != '\0';
      ch++);

      if (ch == maxlen) {
      /* unterminated */
      errno = EFAULT;
      return -1;
      }

      *rval = ch;
      return 0;
      }

      /* we've been doing unix wrong since 1982 */

      In conversation about 17 days ago permalink
    • Embed this notice
      Leah Rowe is not a Rowebot (libreleah@mas.to)'s status on Sunday, 22-Mar-2026 20:44:18 JST Leah Rowe is not a Rowebot Leah Rowe is not a Rowebot
      in reply to
      • Howard Chu @ Symas

      @hyc i use scmp/slen in this code:

      https://av.vimuser.org/mkhtemp-nvmutil-wip.c.txt

      note that this version is work-in-progress (not committed yet). it's for nvmutil, my mac address editor for Intel GbE NVM config, which has now turned into me replacing mktemp.

      i call it: mkhtemp

      dir support added later (for now files only). it resists TOCTUO attacks, and when it's done, standalone mkhutil util will also be modified to work like regular mktemp when you type "mktemp" - otherwise if typing mkhtemp, it will be hard af.

      In conversation about 17 days ago permalink
    • Embed this notice
      Howard Chu @ Symas (hyc@mastodon.social)'s status on Sunday, 22-Mar-2026 20:44:19 JST Howard Chu @ Symas Howard Chu @ Symas
      in reply to

      @libreleah agreed. I wrote LMDB this way as well, return from functions is an error code or 0 for success; any values to be returned go thru the parameter list.

      The C standard string functions suck. https://mastodon.social/@hyc/111596133680619519

      In conversation about 17 days ago permalink

      Attachments

      1. No result found on File_thumbnail lookup.
        Howard Chu @ Symas (@hyc@mastodon.social)
        from Howard Chu @ Symas
        It's all simple enough to fit in a 200char tweet, too but I can't link to that since my twitter account is dead... char *stecpy(char *dst, const char *src, const char *end) { while (*src && dst < end) *dst++ = *src++; if (dst == end) dst--; *dst = '\0'; return dst; } main() { char buf[64]; char *ptr, *end = buf+sizeof(buf); ptr = stecpy(buf, "hello", end); ptr = stecpy(ptr, " world", end); }

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.