mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-07-23 11:20:53 -05:00
chore: eliminate compilation warnings under MSVC (#1170)
This commit is contained in:
18
thirdparty/darts.h
vendored
18
thirdparty/darts.h
vendored
@@ -845,7 +845,7 @@ inline void BitVector::build() {
|
||||
|
||||
num_ones_ = 0;
|
||||
for (std::size_t i = 0; i < units_.size(); ++i) {
|
||||
ranks_[i] = num_ones_;
|
||||
ranks_[i] = static_cast<id_type>(num_ones_);
|
||||
num_ones_ += pop_count(units_[i]);
|
||||
}
|
||||
}
|
||||
@@ -1769,7 +1769,7 @@ id_type DoubleArrayBuilder::arrange_from_keyset(const Keyset<T> &keyset,
|
||||
|
||||
inline id_type DoubleArrayBuilder::find_valid_offset(id_type id) const {
|
||||
if (extras_head_ >= units_.size()) {
|
||||
return units_.size() | (id & LOWER_MASK);
|
||||
return static_cast<id_type>(units_.size()) | (id & LOWER_MASK);
|
||||
}
|
||||
|
||||
id_type unfixed_id = extras_head_;
|
||||
@@ -1781,7 +1781,7 @@ inline id_type DoubleArrayBuilder::find_valid_offset(id_type id) const {
|
||||
unfixed_id = extras(unfixed_id).next();
|
||||
} while (unfixed_id != extras_head_);
|
||||
|
||||
return units_.size() | (id & LOWER_MASK);
|
||||
return static_cast<id_type>(units_.size()) | (id & LOWER_MASK);
|
||||
}
|
||||
|
||||
inline bool DoubleArrayBuilder::is_valid_offset(id_type id,
|
||||
@@ -1812,7 +1812,7 @@ inline void DoubleArrayBuilder::reserve_id(id_type id) {
|
||||
if (id == extras_head_) {
|
||||
extras_head_ = extras(id).next();
|
||||
if (extras_head_ == id) {
|
||||
extras_head_ = units_.size();
|
||||
extras_head_ = static_cast<id_type>(units_.size());
|
||||
}
|
||||
}
|
||||
extras(extras(id).prev()).set_next(extras(id).next());
|
||||
@@ -1821,8 +1821,8 @@ inline void DoubleArrayBuilder::reserve_id(id_type id) {
|
||||
}
|
||||
|
||||
inline void DoubleArrayBuilder::expand_units() {
|
||||
id_type src_num_units = units_.size();
|
||||
id_type src_num_blocks = num_blocks();
|
||||
id_type src_num_units = static_cast<id_type>(units_.size());
|
||||
id_type src_num_blocks = static_cast<id_type>(num_blocks());
|
||||
|
||||
id_type dest_num_units = src_num_units + BLOCK_SIZE;
|
||||
id_type dest_num_blocks = src_num_blocks + 1;
|
||||
@@ -1834,7 +1834,7 @@ inline void DoubleArrayBuilder::expand_units() {
|
||||
units_.resize(dest_num_units);
|
||||
|
||||
if (dest_num_blocks > NUM_EXTRA_BLOCKS) {
|
||||
for (std::size_t id = src_num_units; id < dest_num_units; ++id) {
|
||||
for (id_type id = src_num_units; id < dest_num_units; ++id) {
|
||||
extras(id).set_is_used(false);
|
||||
extras(id).set_is_fixed(false);
|
||||
}
|
||||
@@ -1858,9 +1858,9 @@ inline void DoubleArrayBuilder::expand_units() {
|
||||
inline void DoubleArrayBuilder::fix_all_blocks() {
|
||||
id_type begin = 0;
|
||||
if (num_blocks() > NUM_EXTRA_BLOCKS) {
|
||||
begin = num_blocks() - NUM_EXTRA_BLOCKS;
|
||||
begin = static_cast<id_type>(num_blocks() - NUM_EXTRA_BLOCKS);
|
||||
}
|
||||
id_type end = num_blocks();
|
||||
id_type end = static_cast<id_type>(num_blocks());
|
||||
|
||||
for (id_type block_id = begin; block_id != end; ++block_id) {
|
||||
fix_block(block_id);
|
||||
|
||||
14
thirdparty/stb_image_write.h
vendored
14
thirdparty/stb_image_write.h
vendored
@@ -257,6 +257,10 @@ int stbi_write_tga_with_rle = 1;
|
||||
int stbi_write_force_png_filter = -1;
|
||||
#endif
|
||||
|
||||
#ifndef STBMIN
|
||||
#define STBMIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif // STBMIN
|
||||
|
||||
static int stbi__flip_vertically_on_write = 0;
|
||||
|
||||
STBIWDEF void stbi_flip_vertically_on_write(int flag)
|
||||
@@ -1179,8 +1183,8 @@ STBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int s
|
||||
if (!zlib) return 0;
|
||||
|
||||
if(parameters != NULL) {
|
||||
param_length = strlen(parameters);
|
||||
param_length += strlen("parameters") + 1; // For the name and the null-byte
|
||||
param_length = (int)strlen(parameters);
|
||||
param_length += (int)strlen("parameters") + 1; // For the name and the null-byte
|
||||
}
|
||||
|
||||
// each tag requires 12 bytes of overhead
|
||||
@@ -1526,11 +1530,11 @@ static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, in
|
||||
if(parameters != NULL) {
|
||||
stbiw__putc(s, 0xFF /* comnent */ );
|
||||
stbiw__putc(s, 0xFE /* marker */ );
|
||||
size_t param_length = std::min(2 + strlen("parameters") + 1 + strlen(parameters) + 1, (size_t) 0xFFFF);
|
||||
int param_length = STBMIN(2 + (int)strlen("parameters") + 1 + (int)strlen(parameters) + 1, 0xFFFF);
|
||||
stbiw__putc(s, param_length >> 8); // no need to mask, length < 65536
|
||||
stbiw__putc(s, param_length & 0xFF);
|
||||
s->func(s->context, (void*)"parameters", strlen("parameters") + 1); // std::string is zero-terminated
|
||||
s->func(s->context, (void*)parameters, std::min(param_length, (size_t) 65534) - 2 - strlen("parameters") - 1);
|
||||
s->func(s->context, (void*)"parameters", (int)strlen("parameters") + 1); // std::string is zero-terminated
|
||||
s->func(s->context, (void*)parameters, STBMIN(param_length, 65534) - 2 - (int)strlen("parameters") - 1);
|
||||
if(param_length > 65534) stbiw__putc(s, 0); // always zero-terminate for safety
|
||||
if(param_length & 1) stbiw__putc(s, 0xFF); // pad to even length
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user