Sha256: d9d6abc1dd70f297f8c51ce23a52d8c62d43b306d05779d42a5bc1703eb11a36
Contents?: true
Size: 1.59 KB
Versions: 3
Compression:
Stored size: 1.59 KB
Contents
/* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_stackstr_h__ #define INCLUDE_stackstr_h__ #include "git2_util.h" typedef struct { /* Length of / number of bytes used by `data`. */ size_t len; /* Size of the allocated `data` buffer. */ size_t size; /* The actual string buffer data. */ char data[GIT_FLEX_ARRAY]; } git_staticstr; #define git_staticstr_with_size(__size) \ struct { \ size_t len; \ size_t size; \ char data[__size]; \ } #define git_staticstr_init(__str, __size) \ do { \ (__str)->len = 0; \ (__str)->size = __size; \ (__str)->data[0] = '\0'; \ } while(0) #define git_staticstr_offset(__str) \ ((__str)->data + (__str)->len) #define git_staticstr_remain(__str) \ ((__str)->len > (__str)->size ? 0 : ((__str)->size - (__str)->len)) #define git_staticstr_increase(__str, __len) \ do { ((__str)->len += __len); } while(0) #define git_staticstr_consume_bytes(__str, __len) \ do { git_staticstr_consume(__str, (__str)->data + __len); } while(0) #define git_staticstr_consume(__str, __end) \ do { \ if (__end > (__str)->data && \ __end <= (__str)->data + (__str)->len) { \ size_t __consumed = __end - (__str)->data; \ memmove((__str)->data, __end, (__str)->len - __consumed); \ (__str)->len -= __consumed; \ (__str)->data[(__str)->len] = '\0'; \ } \ } while(0) #define git_staticstr_clear(__str) \ do { \ (__str)->len = 0; \ (__str)->data[0] = 0; \ } while(0) #endif
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rugged-1.9.0 | vendor/libgit2/src/util/staticstr.h |
rugged-1.7.2 | vendor/libgit2/src/util/staticstr.h |
rugged-1.7.1 | vendor/libgit2/src/util/staticstr.h |