ewah: add convenient wrapper ewah_serialize_strbuf()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
27b099ae87
commit
be0d9d5323
@ -19,6 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "git-compat-util.h"
|
#include "git-compat-util.h"
|
||||||
#include "ewok.h"
|
#include "ewok.h"
|
||||||
|
#include "strbuf.h"
|
||||||
|
|
||||||
int ewah_serialize_native(struct ewah_bitmap *self, int fd)
|
int ewah_serialize_native(struct ewah_bitmap *self, int fd)
|
||||||
{
|
{
|
||||||
@ -110,6 +111,18 @@ int ewah_serialize(struct ewah_bitmap *self, int fd)
|
|||||||
return ewah_serialize_to(self, write_helper, (void *)(intptr_t)fd);
|
return ewah_serialize_to(self, write_helper, (void *)(intptr_t)fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int write_strbuf(void *user_data, const void *data, size_t len)
|
||||||
|
{
|
||||||
|
struct strbuf *sb = user_data;
|
||||||
|
strbuf_add(sb, data, len);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ewah_serialize_strbuf(struct ewah_bitmap *self, struct strbuf *sb)
|
||||||
|
{
|
||||||
|
return ewah_serialize_to(self, write_strbuf, sb);
|
||||||
|
}
|
||||||
|
|
||||||
int ewah_read_mmap(struct ewah_bitmap *self, const void *map, size_t len)
|
int ewah_read_mmap(struct ewah_bitmap *self, const void *map, size_t len)
|
||||||
{
|
{
|
||||||
const uint8_t *ptr = map;
|
const uint8_t *ptr = map;
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
# define ewah_calloc xcalloc
|
# define ewah_calloc xcalloc
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct strbuf;
|
||||||
typedef uint64_t eword_t;
|
typedef uint64_t eword_t;
|
||||||
#define BITS_IN_WORD (sizeof(eword_t) * 8)
|
#define BITS_IN_WORD (sizeof(eword_t) * 8)
|
||||||
|
|
||||||
@ -98,6 +99,7 @@ int ewah_serialize_to(struct ewah_bitmap *self,
|
|||||||
void *out);
|
void *out);
|
||||||
int ewah_serialize(struct ewah_bitmap *self, int fd);
|
int ewah_serialize(struct ewah_bitmap *self, int fd);
|
||||||
int ewah_serialize_native(struct ewah_bitmap *self, int fd);
|
int ewah_serialize_native(struct ewah_bitmap *self, int fd);
|
||||||
|
int ewah_serialize_strbuf(struct ewah_bitmap *self, struct strbuf *);
|
||||||
|
|
||||||
int ewah_deserialize(struct ewah_bitmap *self, int fd);
|
int ewah_deserialize(struct ewah_bitmap *self, int fd);
|
||||||
int ewah_read_mmap(struct ewah_bitmap *self, const void *map, size_t len);
|
int ewah_read_mmap(struct ewah_bitmap *self, const void *map, size_t len);
|
||||||
|
@ -41,13 +41,6 @@ int read_link_extension(struct index_state *istate,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int write_strbuf(void *user_data, const void *data, size_t len)
|
|
||||||
{
|
|
||||||
struct strbuf *sb = user_data;
|
|
||||||
strbuf_add(sb, data, len);
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
int write_link_extension(struct strbuf *sb,
|
int write_link_extension(struct strbuf *sb,
|
||||||
struct index_state *istate)
|
struct index_state *istate)
|
||||||
{
|
{
|
||||||
@ -55,8 +48,8 @@ int write_link_extension(struct strbuf *sb,
|
|||||||
strbuf_add(sb, si->base_sha1, 20);
|
strbuf_add(sb, si->base_sha1, 20);
|
||||||
if (!si->delete_bitmap && !si->replace_bitmap)
|
if (!si->delete_bitmap && !si->replace_bitmap)
|
||||||
return 0;
|
return 0;
|
||||||
ewah_serialize_to(si->delete_bitmap, write_strbuf, sb);
|
ewah_serialize_strbuf(si->delete_bitmap, sb);
|
||||||
ewah_serialize_to(si->replace_bitmap, write_strbuf, sb);
|
ewah_serialize_strbuf(si->replace_bitmap, sb);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user