bincode: change signature of getstr to receive str destination

laumann
Oct 4, 2023, 9:16 PM
7NQTS36DJ6GRXMZDNMORKPWF7VBESQY4DH2XFI7VI2A2JVMFIK5AC

Dependencies

  • [2] HFRFMZ63 bincode: remember to advance buf
  • [3] 5D2IYPL7 change: introduce changestore, print deleted lines
  • [4] YFBKBUKB change: rename binstat -> bc
  • [5] 33ZXTRXR change: decode and print file deletions
  • [6] 2LYNPDBT change: decode and print solve/unsolve name conflicts
  • [7] TGT4VSME change: decode FILE_ADD
  • [8] JVU3TTT5 all: switch away from typedefing anonymous structs
  • [9] Y26WT3ZF change: decode message, description and timestamp
  • [10] JAGXXSR7 change: initial work on decoding hunks
  • [11] FMYCPGKD change: extract hash list decoding into reused function
  • [12] XTVLIC24 change: refactor to print_change()
  • [13] 7WA2F6RS change: decode resurrectzombies, addroot, delroot
  • [14] XTKRT6OQ format the codebase
  • [15] LCEKN25G change: parse authors
  • [16] 2U7P5SFQ Change struct names "struct foo -> typedef struct Foo"
  • [17] O7XAUFM6 change: decode and print {,un}solve order conflicts
  • [18] NEORNIZE change: decode and print file moves
  • [19] 2YF4J5SJ change: decode and print file undel
  • [20] 4RYULBDD bincode: introduce a bincode_state struct
  • [21] ZKAOPMCH change: Implement decoding of edits, atoms, positions, among others
  • [22] VXGUQZIV bincode: rework so functions advance pointer
  • [23] LVX6U4EK change: decode metadata bytes
  • [24] QYRJIOYP change: separate decoding and printing of hashed struct
  • [25] QSQNGA5K changestore: load changes on demand
  • [*] Q7TKZCJP Add initial support for reading the offsets from a (fixed) change

Change contents

  • replacement in change.c at line 273
    [4.2731][4.2731:2771]()
    local->path = bincode_getstr(bc, len);
    [4.2731]
    [4.2771]
    local->path = xmalloc(len + 1);
    bincode_getstr(bc, local->path, len);
  • replacement in change.c at line 284
    [4.2931][4.2931:2970]()
    *encoding = bincode_getstr(bc, len);
    [4.2931]
    [5.3751]
    *encoding = xmalloc(len + 1);
    bincode_getstr(bc, *encoding, len);
  • replacement in change.c at line 326
    [4.3683][4.3683:3734]()
    bhunk->fileadd.path = bincode_getstr(bc, slen);
    [4.3683]
    [4.3734]
    bhunk->fileadd.path = xmalloc(slen + 1);
    bincode_getstr(bc, bhunk->fileadd.path, slen);
  • replacement in change.c at line 334
    [4.3920][4.3920:3972]()
    bhunk->filemove.path = bincode_getstr(bc, slen);
    [4.3920]
    [5.0]
    bhunk->filemove.path = xmalloc(slen + 1);
    bincode_getstr(bc, bhunk->filemove.path, slen);
  • replacement in change.c at line 343
    [4.4134][4.4134:4185]()
    bhunk->filedel.path = bincode_getstr(bc, slen);
    [4.4134]
    [4.4185]
    bhunk->filedel.path = xmalloc(slen + 1);
    bincode_getstr(bc, bhunk->filedel.path, slen);
  • replacement in change.c at line 354
    [4.4389][4.4389:4442]()
    bhunk->fileundel.path = bincode_getstr(bc, slen);
    [4.4389]
    [4.4442]
    bhunk->fileundel.path = xmalloc(slen + 1);
    bincode_getstr(bc, bhunk->fileundel.path, slen);
  • replacement in change.c at line 377
    [4.4765][5.374:409](),[5.374][5.374:409](),[5.409][4.4766:4796]()
    bhunk->solvenameconflict.path =
    bincode_getstr(bc, slen);
    [4.4765]
    [5.444]
    bhunk->solvenameconflict.path = xmalloc(slen + 1);
    bincode_getstr(bc, bhunk->solvenameconflict.path, slen);
  • replacement in change.c at line 383
    [4.4888][5.589:626](),[5.589][5.589:626](),[5.626][4.4889:4919]()
    bhunk->unsolvenameconflict.path =
    bincode_getstr(bc, slen);
    [4.4888]
    [5.306]
    bhunk->unsolvenameconflict.path = xmalloc(slen + 1);
    bincode_getstr(
    bc, bhunk->unsolvenameconflict.path, slen
    );
  • replacement in change.c at line 455
    [4.5414][4.5414:5466]()
    hashed->header.message = bincode_getstr(&bc, len);
    [4.5414]
    [5.853]
    hashed->header.message = xmalloc(len + 1);
    bincode_getstr(&bc, hashed->header.message, len);
  • replacement in change.c at line 466
    [4.5523][4.5523:5580]()
    hashed->header.description = bincode_getstr(&bc, len);
    [4.5523]
    [5.259]
    hashed->header.description = xmalloc(len + 1);
    bincode_getstr(&bc, hashed->header.description, len);
  • replacement in change.c at line 475
    [5.1248][4.5610:5664]()
    hashed->header.timestamp = bincode_getstr(&bc, len);
    [5.1248]
    [5.354]
    hashed->header.timestamp = xmalloc(len + 1);
    bincode_getstr(&bc, hashed->header.timestamp, len);
  • replacement in change.c at line 495
    [5.677][4.5779:5809]()
    bincode_getstr(&bc, len);
    [5.677]
    [4.5809]
    xmalloc(len + 1);
    bincode_getstr(
    &bc,
    hashed->header.authors.map[i].entries[j].key,
    len
    );
  • replacement in change.c at line 503
    [5.730][4.5840:5870]()
    bincode_getstr(&bc, len);
    [5.730]
    [5.1172]
    xmalloc(len + 1);
    bincode_getstr(
    &bc,
    hashed->header.authors.map[i].entries[j].value,
    len
    );
  • replacement in change.c at line 747
    [5.834][5.834:875]()
    m->basename = bincode_getstr(&bc, len);
    [5.834]
    [3.5076]
    m->basename = xmalloc(len + 1);
    bincode_getstr(&bc, m->basename, len);
  • replacement in bincode.h at line 37
    [5.2269][5.2269:2498]()
    * Allocate and return a string of the given length.
    *
    * The memory allocated shall be the given length plus one, to hold the
    * terminating zero.
    *
    * Returns the allocated string. The caller is responsible for deallocating.
    [5.2269]
    [5.2498]
    * Fill in a string of the given length, the destination should have
    * sufficient space.
  • replacement in bincode.h at line 40
    [5.2502][5.4766:4814]()
    char *bincode_getstr(struct bincode *, size_t);
    [5.2502]
    [5.4814]
    void bincode_getstr(struct bincode *, char *, size_t);
  • edit in bincode.c at line 3
    [5.2772][5.2772:2792]()
    #include <stdlib.h>
  • replacement in bincode.c at line 67
    [5.3322][5.3322:3329](),[5.3329][5.5014:5060]()
    char *
    bincode_getstr(struct bincode *s, size_t len)
    [5.3322]
    [5.3368]
    void
    bincode_getstr(struct bincode *s, char *str, size_t len)
  • replacement in bincode.c at line 70
    [5.3370][5.3370:3382](),[5.3382][5.1566:1579](),[5.1579][5.3382:3383](),[5.3382][5.3382:3383](),[5.3383][5.1580:1593](),[5.1593][5.3383:3408](),[5.3383][5.3383:3408](),[5.3408][5.1594:1616](),[5.959][5.3430:3448](),[5.1616][5.3430:3448](),[5.3430][5.3430:3448](),[5.3448][2.119:120]()
    char *str;
    uint8_t *b;
    b = s->buf;
    str = xmalloc(len + 1);
    memcpy(str, b, len);
    str[len] = '\0';
    [5.3370]
    [2.120]
    memcpy(str, s->buf, len);
  • replacement in bincode.c at line 73
    [5.3449][5.3449:3462]()
    return str;
    [5.1635]
    [5.364]
    str[len] = '\0';