Skip to content

Commit

Permalink
Use uint64_t for memory limit and cap it to SIZE_MAX (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
waahm7 authored Jan 26, 2024
1 parent 73d3c86 commit 63da70e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions include/aws/s3/s3_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,8 @@ struct aws_s3_client_config {
/* Throughput target in gigabits per second (Gbps) that we are trying to reach. */
double throughput_target_gbps;

/* How much memory can we use. */
size_t memory_limit_in_bytes;
/* How much memory can we use. This will be capped to SIZE_MAX */
uint64_t memory_limit_in_bytes;

/* Retry strategy to use. If NULL, a default retry strategy will be used. */
struct aws_retry_strategy *retry_strategy;
Expand Down
7 changes: 6 additions & 1 deletion source/s3_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,12 @@ struct aws_s3_client *aws_s3_client_new(
}
#endif
} else {
mem_limit = client_config->memory_limit_in_bytes;
// cap memory limit to SIZE_MAX
if (client_config->memory_limit_in_bytes > SIZE_MAX) {
mem_limit = SIZE_MAX;
} else {
mem_limit = (size_t)client_config->memory_limit_in_bytes;
}
}

size_t part_size = s_default_part_size;
Expand Down

0 comments on commit 63da70e

Please sign in to comment.