Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Commits on Sep 30, 2007
  1. @MadCoder @gitster

    strbuf_read_file enhancement, and use it.

    MadCoder authored gitster committed
    * make strbuf_read_file take a size hint (works like strbuf_read)
    * use it in a couple of places.
    
    Signed-off-by: Pierre Habouzit <madcoder@debian.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Sep 29, 2007
  1. @MadCoder @gitster

    strbuf change: be sure ->buf is never ever NULL.

    MadCoder authored gitster committed
    For that purpose, the ->buf is always initialized with a char * buf living
    in the strbuf module. It is made a char * so that we can sloppily accept
    things that perform: sb->buf[0] = '\0', and because you can't pass "" as an
    initializer for ->buf without making gcc unhappy for very good reasons.
    
    strbuf_init/_detach/_grow have been fixed to trust ->alloc and not ->buf
    anymore.
    
    as a consequence strbuf_detach is _mandatory_ to detach a buffer, copying
    ->buf isn't an option anymore, if ->buf is going to escape from the scope,
    and eventually be free'd.
    
    API changes:
      * strbuf_setlen now always works, so just make strbuf_reset a convenience
        macro.
      * strbuf_detatch takes a size_t* optional argument (meaning it can be
        NULL) to copy the buffer's len, as it was needed for this refactor to
        make the code more readable, and working like the callers.
    
    Signed-off-by: Pierre Habouzit <madcoder@debian.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Sep 26, 2007
  1. @MadCoder @gitster

    Add strbuf_cmp.

    MadCoder authored gitster committed
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Sep 21, 2007
  1. @MadCoder @gitster

    strbuf API additions and enhancements.

    MadCoder authored gitster committed
    Add strbuf_remove, change strbuf_insert:
      As both are special cases of strbuf_splice, implement them as such.
      gcc is able to do the math and generate almost optimal code this way.
    
    Add strbuf_swap:
      Exchange the values of its arguments.
      Use it in fast-import.c
    
    Also fix spacing issues in strbuf.h
    
    Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Commits on Sep 18, 2007
  1. @MadCoder @gitster

    Drop strbuf's 'eof' marker, and make read_line a first class citizen.

    MadCoder authored gitster committed
    read_line is now strbuf_getline, and is a first class citizen, it returns 0
    when reading a line worked, EOF else.
    
    The ->eof marker was used non-locally by fast-import.c, mimic the same
    behaviour using a static int in "read_next_command", that now returns -1 on
    EOF, and avoids to call strbuf_getline when it's in EOF state.
    
    Also no longer automagically strbuf_release the buffer, it's counter
    intuitive and breaks fast-import in a very subtle way.
    
    Note: being at EOF implies that command_buf.len == 0.
    
    Signed-off-by: Pierre Habouzit <madcoder@debian.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Sep 17, 2007
  1. @MadCoder @gitster

    Now that cache.h needs strbuf.h, remove useless includes.

    MadCoder authored gitster committed
    Signed-off-by: Pierre Habouzit <madcoder@debian.org>
    Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @MadCoder @gitster

    New strbuf APIs: splice and attach.

    MadCoder authored gitster committed
    * strbuf_splice replace a portion of the buffer with another.
    * strbuf_attach replace a strbuf buffer with the given one, that should be
      malloc'ed. Then it enforces strbuf's invariants. If alloc > len, then this
      function has negligible cost, else it will perform a realloc, possibly
      with a cost.
    
    Also some style issues are fixed now.
    
    Signed-off-by: Pierre Habouzit <madcoder@debian.org>
    Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Sep 10, 2007
  1. @MadCoder @gitster

    Strbuf API extensions and fixes.

    MadCoder authored gitster committed
      * Add strbuf_rtrim to remove trailing spaces.
      * Add strbuf_insert to insert data at a given position.
      * Off-by one fix in strbuf_addf: strbuf_avail() does not counts the final
        \0 so the overflow test for snprintf is the strict comparison. This is
        not critical as the growth mechanism chosen will always allocate _more_
        memory than asked, so the second test will not fail. It's some kind of
        miracle though.
      * Add size extension hints for strbuf_init and strbuf_read. If 0, default
        applies, else:
          + initial buffer has the given size for strbuf_init.
          + first growth checks it has at least this size rather than the
            default 8192.
    
    Signed-off-by: Pierre Habouzit <madcoder@debian.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Sep 7, 2007
  1. @MadCoder @gitster

    Rework strbuf API and semantics.

    MadCoder authored gitster committed
      The gory details are explained in strbuf.h. The change of semantics this
    patch enforces is that the embeded buffer has always a '\0' character after
    its last byte, to always make it a C-string. The offs-by-one changes are all
    related to that very change.
    
      A strbuf can be used to store byte arrays, or as an extended string
    library. The `buf' member can be passed to any C legacy string function,
    because strbuf operations always ensure there is a terminating \0 at the end
    of the buffer, not accounted in the `len' field of the structure.
    
      A strbuf can be used to generate a string/buffer whose final size is not
    really known, and then "strbuf_detach" can be used to get the built buffer,
    and keep the wrapping "strbuf" structure usable for further work again.
    
      Other interesting feature: strbuf_grow(sb, size) ensure that there is
    enough allocated space in `sb' to put `size' new octets of data in the
    buffer. It helps avoiding reallocating data for nothing when the problem the
    strbuf helps to solve has a known typical size.
    
    Signed-off-by: Pierre Habouzit <madcoder@debian.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Something went wrong with that request. Please try again.