git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCHv3] attr: convert to new threadsafe API

From
Stefan Beller <sbeller@google.com>
Date
Oct 13, 2016, 22:08 UTC
Message-ID
<CAGZ79kasCEWijdUe24mTy9n--BX2=ar4V-hvjXHqEm2sVzjk+g@mail.gmail.com>
In-Reply-To
<CAGZ79kYEefzKJT5TLXaGV0ZYoW=OUzrRBPTOovDG0ofO8-i5Jg@mail.gmail.com>
> On Wed, Oct 12, 2016 at 4:33 PM, Junio C Hamano <gitster@pobox.com> wrote:
> so I am hoping that we won't have to do this uglier variant
---8<--- attr.h:
...
struct git_attr_result {
    int check_nr;
    /* Whether is was statically allocated and cannot be resized. */
    int static_alloc;
    const char *value[FLEX_ARRAY];
};
/* create a pointer pointing to a git_attr_result with a given size: */
#define GIT_ATTR_RESULT_INIT_FOR(name, size) \
    struct { \
        int check_nr; \
        int static_alloc; \
        const char *value[size]; \
    } local_##name; \
    struct git_attr_result *name = \
        (struct git_attr_result *)&(local_##name); \
    local_##name.static_alloc = 1;
...
---8<--- e.g. ws.c:
    static struct git_attr_check *attr_whitespace_rule;
    GIT_ATTR_RESULT_INIT_FOR(result, 1);
    git_attr_check_initl(&attr_whitespace_rule, "whitespace", NULL);
    if (!git_check_attr(pathname, attr_whitespace_rule, result)) {
        if (ATTR_TRUE(result->value[0])) {
            ...
        } else if (ATTR_FALSE(result->value[0])) {
            ...
Previous: Stefan BellerNext: Junio C Hamano
Message 4 of 9 in “[PATCHv3] attr: convert to new threadsafe API”
  1. Stefan BellerOct 12, 2016
  2. Junio C HamanoOct 12, 2016
  3. Stefan BellerOct 13, 2016
  4. Stefan BellerOct 13, 2016
  5. Junio C HamanoOct 14, 2016
  6. Stefan BellerOct 18, 2016
  7. Junio C HamanoOct 19, 2016
  8. Stefan BellerOct 19, 2016
  9. Junio C HamanoOct 19, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.