Commit 60e15ecd by Edward Thomson

packbuilder: `size_t` all the things

After 1cd65991, we were passing a pointer to an `unsigned long` to
a function that now expected a pointer to a `size_t`.  These types
differ on 64-bit Windows, which means that we trash the stack.

Use `size_t`s in the packbuilder to avoid this.
parent 581a4d39
......@@ -51,6 +51,13 @@ v0.24 + 1
### Breaking API changes
* `git_packbuilder_object_count` and `git_packbuilder_written` now
return a `size_t` instead of a `uint32_t` for more thorough
compatibility with the rest of the library.
* `git_packbuiler_progress` now provides explicitly sized `uint32_t`
values instead of `unsigned int`.
v0.24
-------
......
......@@ -196,7 +196,7 @@ GIT_EXTERN(int) git_packbuilder_foreach(git_packbuilder *pb, git_packbuilder_for
* @param pb the packbuilder
* @return the number of objects in the packfile
*/
GIT_EXTERN(uint32_t) git_packbuilder_object_count(git_packbuilder *pb);
GIT_EXTERN(size_t) git_packbuilder_object_count(git_packbuilder *pb);
/**
* Get the number of objects the packbuilder has already written out
......@@ -204,13 +204,13 @@ GIT_EXTERN(uint32_t) git_packbuilder_object_count(git_packbuilder *pb);
* @param pb the packbuilder
* @return the number of objects which have already been written
*/
GIT_EXTERN(uint32_t) git_packbuilder_written(git_packbuilder *pb);
GIT_EXTERN(size_t) git_packbuilder_written(git_packbuilder *pb);
/** Packbuilder progress notification function */
typedef int (*git_packbuilder_progress)(
int stage,
unsigned int current,
unsigned int total,
uint32_t current,
uint32_t total,
void *payload);
/**
......
......@@ -42,8 +42,8 @@ typedef struct git_pobject {
* me */
void *delta_data;
unsigned long delta_size;
unsigned long z_delta_size;
size_t delta_size;
size_t z_delta_size;
int written:1,
recursing:1,
......@@ -66,10 +66,11 @@ struct git_packbuilder {
uint32_t nr_objects,
nr_deltified,
nr_alloc,
nr_written,
nr_remaining;
size_t nr_alloc;
git_pobject *object_list;
git_oidmap *object_ix;
......@@ -85,13 +86,13 @@ struct git_packbuilder {
git_cond progress_cond;
/* configs */
uint64_t delta_cache_size;
uint64_t max_delta_cache_size;
uint64_t cache_max_small_delta_size;
uint64_t big_file_threshold;
uint64_t window_memory_limit;
size_t delta_cache_size;
size_t max_delta_cache_size;
size_t cache_max_small_delta_size;
size_t big_file_threshold;
size_t window_memory_limit;
int nr_threads; /* nr of threads to use */
unsigned int nr_threads; /* nr of threads to use */
git_packbuilder_progress progress_cb;
void *progress_cb_payload;
......
......@@ -284,7 +284,7 @@ static int create_binary(
size_t b_datalen)
{
git_buf deflate = GIT_BUF_INIT, delta = GIT_BUF_INIT;
unsigned long delta_data_len;
size_t delta_data_len;
int error;
/* The git_delta function accepts unsigned long only */
......@@ -310,7 +310,7 @@ static int create_binary(
if (error == 0) {
error = git_zstream_deflatebuf(
&delta, delta_data, (size_t)delta_data_len);
&delta, delta_data, delta_data_len);
git__free(delta_data);
} else if (error == GIT_EBUFS) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment