Skip to content

Commit 3983d2f

Browse files
committed
Reviewed uses of reinterpret_cast
1 parent 3454061 commit 3983d2f

39 files changed

+98
-97
lines changed

api/baseapi.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ size_t TessBaseAPI::getOpenCLDevice(void **data) {
165165
#if USE_DEVICE_SELECTION
166166
ds_device device = OpenclDevice::getDeviceSelection();
167167
if (device.type == DS_DEVICE_OPENCL_DEVICE) {
168-
*data = reinterpret_cast<void*>(new cl_device_id);
168+
*data = new cl_device_id;
169169
memcpy(*data, &device.oclDeviceID, sizeof(cl_device_id));
170170
return sizeof(cl_device_id);
171171
}

ccmain/equationdetect.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,24 @@ namespace tesseract {
5656
// Utility ColParition sort functions.
5757
///////////////////////////////////////////////////////////////////////////
5858
static int SortCPByTopReverse(const void* p1, const void* p2) {
59-
const ColPartition* cp1 = *reinterpret_cast<ColPartition* const*>(p1);
60-
const ColPartition* cp2 = *reinterpret_cast<ColPartition* const*>(p2);
59+
const ColPartition* cp1 = *static_cast<ColPartition* const*>(p1);
60+
const ColPartition* cp2 = *static_cast<ColPartition* const*>(p2);
6161
ASSERT_HOST(cp1 != NULL && cp2 != NULL);
6262
const TBOX &box1(cp1->bounding_box()), &box2(cp2->bounding_box());
6363
return box2.top() - box1.top();
6464
}
6565

6666
static int SortCPByBottom(const void* p1, const void* p2) {
67-
const ColPartition* cp1 = *reinterpret_cast<ColPartition* const*>(p1);
68-
const ColPartition* cp2 = *reinterpret_cast<ColPartition* const*>(p2);
67+
const ColPartition* cp1 = *static_cast<ColPartition* const*>(p1);
68+
const ColPartition* cp2 = *static_cast<ColPartition* const*>(p2);
6969
ASSERT_HOST(cp1 != NULL && cp2 != NULL);
7070
const TBOX &box1(cp1->bounding_box()), &box2(cp2->bounding_box());
7171
return box1.bottom() - box2.bottom();
7272
}
7373

7474
static int SortCPByHeight(const void* p1, const void* p2) {
75-
const ColPartition* cp1 = *reinterpret_cast<ColPartition* const*>(p1);
76-
const ColPartition* cp2 = *reinterpret_cast<ColPartition* const*>(p2);
75+
const ColPartition* cp1 = *static_cast<ColPartition* const*>(p1);
76+
const ColPartition* cp2 = *static_cast<ColPartition* const*>(p2);
7777
ASSERT_HOST(cp1 != NULL && cp2 != NULL);
7878
const TBOX &box1(cp1->bounding_box()), &box2(cp2->bounding_box());
7979
return box1.height() - box2.height();

ccmain/paramsd.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ void ParamsEditor::GetPrefixes(const char* s, STRING* level_one,
184184
// Compare two VC objects by their name.
185185
int ParamContent::Compare(const void* v1, const void* v2) {
186186
const ParamContent* one =
187-
*reinterpret_cast<const ParamContent* const *>(v1);
187+
*static_cast<const ParamContent* const *>(v1);
188188
const ParamContent* two =
189-
*reinterpret_cast<const ParamContent* const *>(v2);
189+
*static_cast<const ParamContent* const *>(v2);
190190
return strcmp(one->GetName(), two->GetName());
191191
}
192192

ccmain/thresholder.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ void ImageThresholder::ThresholdRectToPix(Pix* src_pix,
312312
bool white_result = true;
313313
for (int ch = 0; ch < num_channels; ++ch) {
314314
int pixel = GET_DATA_BYTE(const_cast<void*>(
315-
reinterpret_cast<const void *>(linedata)),
315+
static_cast<const void *>(linedata)),
316316
(x + rect_left_) * num_channels + ch);
317317
if (hi_values[ch] >= 0 &&
318318
(pixel > thresholds[ch]) == (hi_values[ch] == 0)) {

ccstruct/coutln.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ inT16 length //length of loop
9494
pos = startpt;
9595
stepcount = length; // No. of steps.
9696
ASSERT_HOST(length >= 0);
97-
steps = reinterpret_cast<uinT8*>(alloc_mem(step_mem())); // Get memory.
97+
steps = static_cast<uinT8*>(alloc_mem(step_mem())); // Get memory.
9898
memset(steps, 0, step_mem());
9999

100100
lastdir = new_steps[length - 1];
@@ -655,23 +655,23 @@ static void ComputeGradient(const l_uint32* data, int wpl,
655655
int pix_x_y =
656656
x < width && y < height
657657
? GET_DATA_BYTE(
658-
const_cast<void*>(reinterpret_cast<const void*>(line)), x)
658+
const_cast<void*>(static_cast<const void*>(line)), x)
659659
: 255;
660660
int pix_x_prevy =
661661
x < width && y > 0
662662
? GET_DATA_BYTE(
663-
const_cast<void*>(reinterpret_cast<const void*>(line - wpl)), x)
663+
const_cast<void*>(static_cast<const void*>(line - wpl)), x)
664664
: 255;
665665
int pix_prevx_prevy =
666666
x > 0 && y > 0
667667
? GET_DATA_BYTE(
668-
const_cast<void*>(reinterpret_cast<void const*>(line - wpl)),
668+
const_cast<void*>(static_cast<void const*>(line - wpl)),
669669
x - 1)
670670
: 255;
671671
int pix_prevx_y =
672672
x > 0 && y < height
673673
? GET_DATA_BYTE(
674-
const_cast<void*>(reinterpret_cast<const void*>(line)), x - 1)
674+
const_cast<void*>(static_cast<const void*>(line)), x - 1)
675675
: 255;
676676
gradient->set_x(pix_x_y + pix_x_prevy - (pix_prevx_y + pix_prevx_prevy));
677677
gradient->set_y(pix_x_prevy + pix_prevx_prevy - (pix_x_y + pix_prevx_y));
@@ -689,9 +689,9 @@ static bool EvaluateVerticalDiff(const l_uint32* data, int wpl, int diff_sign,
689689
return false;
690690
const l_uint32* line = data + y * wpl;
691691
int pixel1 = GET_DATA_BYTE(
692-
const_cast<void*>(reinterpret_cast<const void*>(line - wpl)), x);
692+
const_cast<void*>(static_cast<const void*>(line - wpl)), x);
693693
int pixel2 =
694-
GET_DATA_BYTE(const_cast<void*>(reinterpret_cast<const void*>(line)), x);
694+
GET_DATA_BYTE(const_cast<void*>(static_cast<const void*>(line)), x);
695695
int diff = (pixel2 - pixel1) * diff_sign;
696696
if (diff > *best_diff) {
697697
*best_diff = diff;
@@ -712,9 +712,9 @@ static bool EvaluateHorizontalDiff(const l_uint32* line, int diff_sign,
712712
if (x <= 0 || x >= width)
713713
return false;
714714
int pixel1 = GET_DATA_BYTE(
715-
const_cast<void*>(reinterpret_cast<const void*>(line)), x - 1);
715+
const_cast<void*>(static_cast<const void*>(line)), x - 1);
716716
int pixel2 =
717-
GET_DATA_BYTE(const_cast<void*>(reinterpret_cast<const void*>(line)), x);
717+
GET_DATA_BYTE(const_cast<void*>(static_cast<const void*>(line)), x);
718718
int diff = (pixel2 - pixel1) * diff_sign;
719719
if (diff > *best_diff) {
720720
*best_diff = diff;

ccstruct/imagedata.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ void FloatWordFeature::FromWordFeatures(
112112
// Sort function to sort first by x-bucket, then by y.
113113
/* static */
114114
int FloatWordFeature::SortByXBucket(const void* v1, const void* v2) {
115-
const FloatWordFeature* f1 = reinterpret_cast<const FloatWordFeature*>(v1);
116-
const FloatWordFeature* f2 = reinterpret_cast<const FloatWordFeature*>(v2);
115+
const FloatWordFeature* f1 = static_cast<const FloatWordFeature*>(v1);
116+
const FloatWordFeature* f2 = static_cast<const FloatWordFeature*>(v2);
117117
int x_diff = f1->x_bucket - f2->x_bucket;
118118
if (x_diff == 0) return f1->y - f2->y;
119119
return x_diff;
@@ -367,7 +367,7 @@ bool ImageData::AddBoxes(const char* box_text) {
367367

368368
// Thread function to call ReCachePages.
369369
void* ReCachePagesFunc(void* data) {
370-
DocumentData* document_data = reinterpret_cast<DocumentData*>(data);
370+
DocumentData* document_data = static_cast<DocumentData*>(data);
371371
document_data->ReCachePages();
372372
return NULL;
373373
}

ccstruct/matrix.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
class BLOB_CHOICE;
3939
class BLOB_CHOICE_LIST;
4040

41-
#define NOT_CLASSIFIED reinterpret_cast<BLOB_CHOICE_LIST*>(0)
41+
#define NOT_CLASSIFIED static_cast<BLOB_CHOICE_LIST*>(0)
4242

4343
// A generic class to hold a 2-D matrix with entries of type T, but can also
4444
// act as a base class for other implementations, such as a triangular or

ccstruct/otsuthr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ void HistogramRect(Pix* src_pix, int channel,
162162
const l_uint32* linedata = srcdata + y * src_wpl;
163163
for (int x = 0; x < width; ++x) {
164164
int pixel = GET_DATA_BYTE(const_cast<void*>(
165-
reinterpret_cast<const void *>(linedata)),
165+
static_cast<const void *>(linedata)),
166166
(x + left) * num_channels + channel);
167167
++histogram[pixel];
168168
}

ccstruct/ratngs.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ class BLOB_CHOICE: public ELIST_LINK
191191
// Sort function for sorting BLOB_CHOICEs in increasing order of rating.
192192
static int SortByRating(const void *p1, const void *p2) {
193193
const BLOB_CHOICE *bc1 =
194-
*reinterpret_cast<const BLOB_CHOICE * const *>(p1);
194+
*static_cast<const BLOB_CHOICE * const *>(p1);
195195
const BLOB_CHOICE *bc2 =
196-
*reinterpret_cast<const BLOB_CHOICE * const *>(p2);
196+
*static_cast<const BLOB_CHOICE * const *>(p2);
197197
return (bc1->rating_ < bc2->rating_) ? -1 : 1;
198198
}
199199

ccstruct/statistc.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -772,8 +772,8 @@ void swap_entries(void *array, // array of entries
772772
char *ptr2;
773773
size_t count; // of bytes
774774

775-
ptr1 = reinterpret_cast<char*>(array) + index1 * size;
776-
ptr2 = reinterpret_cast<char*>(array) + index2 * size;
775+
ptr1 = static_cast<char*>(array) + index1 * size;
776+
ptr2 = static_cast<char*>(array) + index2 * size;
777777
for (count = 0; count < size; count++) {
778778
tmp = *ptr1;
779779
*ptr1++ = *ptr2;

ccstruct/stepblob.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ class C_BLOB:public ELIST_LINK
117117
}
118118

119119
static int SortByXMiddle(const void *v1, const void *v2) {
120-
const C_BLOB* blob1 = *reinterpret_cast<const C_BLOB* const *>(v1);
121-
const C_BLOB* blob2 = *reinterpret_cast<const C_BLOB* const *>(v2);
120+
const C_BLOB* blob1 = *static_cast<const C_BLOB* const *>(v1);
121+
const C_BLOB* blob2 = *static_cast<const C_BLOB* const *>(v2);
122122
return blob1->bounding_box().x_middle() -
123123
blob2->bounding_box().x_middle();
124124
}

ccutil/ambigs.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ class AmbigSpec : public ELIST_LINK {
121121
// in a a sorted AmbigSpec_LIST: [9 1 3], [9 3 4], [9 8], [9, 8 1].
122122
static int compare_ambig_specs(const void *spec1, const void *spec2) {
123123
const AmbigSpec *s1 =
124-
*reinterpret_cast<const AmbigSpec * const *>(spec1);
124+
*static_cast<const AmbigSpec * const *>(spec1);
125125
const AmbigSpec *s2 =
126-
*reinterpret_cast<const AmbigSpec * const *>(spec2);
126+
*static_cast<const AmbigSpec * const *>(spec2);
127127
int result = UnicharIdArrayUtils::compare(s1->wrong_ngram, s2->wrong_ngram);
128128
if (result != 0) return result;
129129
return UnicharIdArrayUtils::compare(s1->correct_fragments,

ccutil/genericvector.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,8 @@ int sort_cmp(const void* t1, const void* t2) {
421421
// return > 0 if t1 > t2
422422
template <typename T>
423423
int sort_ptr_cmp(const void* t1, const void* t2) {
424-
const T* a = *reinterpret_cast<T * const *>(t1);
425-
const T* b = *reinterpret_cast<T * const *>(t2);
424+
const T* a = *static_cast<T * const *>(t1);
425+
const T* b = *static_cast<T * const *>(t2);
426426
if (*a < *b) {
427427
return -1;
428428
} else if (*b < *a) {

ccutil/helpers.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ inline int IntCastRounded(double x) {
182182

183183
// Reverse the order of bytes in a n byte quantity for big/little-endian switch.
184184
inline void ReverseN(void* ptr, int num_bytes) {
185-
char *cptr = reinterpret_cast<char *>(ptr);
185+
char *cptr = static_cast<char *>(ptr);
186186
int halfsize = num_bytes / 2;
187187
for (int i = 0; i < halfsize; ++i) {
188188
char tmp = cptr[i];

ccutil/serialis.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ char* TFile::FGets(char* buffer, int buffer_size) {
9797
int TFile::FReadEndian(void* buffer, int size, int count) {
9898
int num_read = FRead(buffer, size, count);
9999
if (swap_) {
100-
char* char_buffer = reinterpret_cast<char*>(buffer);
100+
char* char_buffer = static_cast<char*>(buffer);
101101
for (int i = 0; i < num_read; ++i, char_buffer += size) {
102102
ReverseN(char_buffer, size);
103103
}
@@ -109,7 +109,7 @@ int TFile::FRead(void* buffer, int size, int count) {
109109
ASSERT_HOST(!is_writing_);
110110
int required_size = size * count;
111111
if (required_size <= 0) return 0;
112-
char* char_buffer = reinterpret_cast<char*>(buffer);
112+
char* char_buffer = static_cast<char*>(buffer);
113113
if (data_->size() - offset_ < required_size)
114114
required_size = data_->size() - offset_;
115115
if (required_size > 0 && char_buffer != NULL)
@@ -150,7 +150,7 @@ int TFile::FWrite(const void* buffer, int size, int count) {
150150
ASSERT_HOST(is_writing_);
151151
int total = size * count;
152152
if (total <= 0) return 0;
153-
const char* buf = reinterpret_cast<const char*>(buffer);
153+
const char* buf = static_cast<const char*>(buffer);
154154
// This isn't very efficient, but memory is so fast compared to disk
155155
// that it is relatively unimportant, and very simple.
156156
for (int i = 0; i < total; ++i)

ccutil/sorthelper.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ class SortHelper {
4242
};
4343
// qsort function to sort by decreasing count.
4444
static int SortPairsByCount(const void* v1, const void* v2) {
45-
const SortPair<T>* p1 = reinterpret_cast<const SortPair<T>*>(v1);
46-
const SortPair<T>* p2 = reinterpret_cast<const SortPair<T>*>(v2);
45+
const SortPair<T>* p1 = static_cast<const SortPair<T>*>(v1);
46+
const SortPair<T>* p2 = static_cast<const SortPair<T>*>(v2);
4747
return p2->count - p1->count;
4848
}
4949
// qsort function to sort by decreasing value.
5050
static int SortPairsByValue(const void* v1, const void* v2) {
51-
const SortPair<T>* p1 = reinterpret_cast<const SortPair<T>*>(v1);
52-
const SortPair<T>* p2 = reinterpret_cast<const SortPair<T>*>(v2);
51+
const SortPair<T>* p1 = static_cast<const SortPair<T>*>(v1);
52+
const SortPair<T>* p2 = static_cast<const SortPair<T>*>(v2);
5353
if (p2->value - p1->value < 0) return -1;
5454
if (p2->value - p1->value > 0) return 1;
5555
return 0;

classify/adaptmatch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2242,7 +2242,7 @@ void Classify::ShowBestMatchFor(int shape_id,
22422242
tprintf("Static Shape ID: %d\n", shape_id);
22432243
ShowMatchDisplay();
22442244
im_.Match(ClassForClassId(PreTrainedTemplates, shape_id),
2245-
AllProtosOn, reinterpret_cast<BIT_VECTOR>(&config_mask),
2245+
AllProtosOn, &config_mask, // TODO: or reinterpret_cast<BIT_VECTOR>(&config_mask) anyway?
22462246
num_features, features, &cn_result,
22472247
classify_adapt_feature_threshold,
22482248
matcher_debug_flags,

classify/cluster.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -1123,9 +1123,9 @@ PROTOTYPE *TestEllipticalProto(CLUSTERER *Clusterer,
11231123
if (TotalDims < N + 1 || TotalDims < 2)
11241124
return NULL;
11251125
const int kMatrixSize = N * N * sizeof(FLOAT32);
1126-
FLOAT32* Covariance = reinterpret_cast<FLOAT32 *>(Emalloc(kMatrixSize));
1127-
FLOAT32* Inverse = reinterpret_cast<FLOAT32 *>(Emalloc(kMatrixSize));
1128-
FLOAT32* Delta = reinterpret_cast<FLOAT32*>(Emalloc(N * sizeof(FLOAT32)));
1126+
FLOAT32* Covariance = static_cast<FLOAT32 *>(Emalloc(kMatrixSize));
1127+
FLOAT32* Inverse = static_cast<FLOAT32 *>(Emalloc(kMatrixSize));
1128+
FLOAT32* Delta = static_cast<FLOAT32*>(Emalloc(N * sizeof(FLOAT32)));
11291129
// Compute a new covariance matrix that only uses essential features.
11301130
for (int i = 0; i < N; ++i) {
11311131
int row_offset = i * N;
@@ -1749,13 +1749,13 @@ BUCKETS *MakeBuckets(DISTRIBUTION Distribution,
17491749
BOOL8 Symmetrical;
17501750

17511751
// allocate memory needed for data structure
1752-
Buckets = reinterpret_cast<BUCKETS*>(Emalloc(sizeof(BUCKETS)));
1752+
Buckets = static_cast<BUCKETS*>(Emalloc(sizeof(BUCKETS)));
17531753
Buckets->NumberOfBuckets = OptimumNumberOfBuckets(SampleCount);
17541754
Buckets->SampleCount = SampleCount;
17551755
Buckets->Confidence = Confidence;
1756-
Buckets->Count = reinterpret_cast<uinT32*>(
1756+
Buckets->Count = static_cast<uinT32*>(
17571757
Emalloc(Buckets->NumberOfBuckets * sizeof(uinT32)));
1758-
Buckets->ExpectedCount = reinterpret_cast<FLOAT32*>(
1758+
Buckets->ExpectedCount = static_cast<FLOAT32*>(
17591759
Emalloc(Buckets->NumberOfBuckets * sizeof(FLOAT32)));
17601760

17611761
// initialize simple fields

classify/clusttool.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ FLOAT32 *ReadNFloats(TFile *fp, uinT16 N, FLOAT32 Buffer[]) {
227227
bool needs_free = false;
228228

229229
if (Buffer == NULL) {
230-
Buffer = reinterpret_cast<FLOAT32*>(Emalloc(N * sizeof(FLOAT32)));
230+
Buffer = static_cast<FLOAT32*>(Emalloc(N * sizeof(FLOAT32)));
231231
needs_free = true;
232232
}
233233

classify/shapetable.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ bool UnicharAndFonts::DeSerialize(TFile* fp) {
7979

8080
// Sort function to sort a pair of UnicharAndFonts by unichar_id.
8181
int UnicharAndFonts::SortByUnicharId(const void* v1, const void* v2) {
82-
const UnicharAndFonts* p1 = reinterpret_cast<const UnicharAndFonts*>(v1);
83-
const UnicharAndFonts* p2 = reinterpret_cast<const UnicharAndFonts*>(v2);
82+
const UnicharAndFonts* p1 = static_cast<const UnicharAndFonts*>(v1);
83+
const UnicharAndFonts* p2 = static_cast<const UnicharAndFonts*>(v2);
8484
return p1->unichar_id - p2->unichar_id;
8585
}
8686

classify/shapetable.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ struct UnicharRating {
5454

5555
// Sort function to sort ratings appropriately by descending rating.
5656
static int SortDescendingRating(const void* t1, const void* t2) {
57-
const UnicharRating* a = reinterpret_cast<const UnicharRating *>(t1);
58-
const UnicharRating* b = reinterpret_cast<const UnicharRating *>(t2);
57+
const UnicharRating* a = static_cast<const UnicharRating *>(t1);
58+
const UnicharRating* b = static_cast<const UnicharRating *>(t2);
5959
if (a->rating > b->rating) {
6060
return -1;
6161
} else if (a->rating < b->rating) {
@@ -100,8 +100,8 @@ struct ShapeRating {
100100

101101
// Sort function to sort ratings appropriately by descending rating.
102102
static int SortDescendingRating(const void* t1, const void* t2) {
103-
const ShapeRating* a = reinterpret_cast<const ShapeRating *>(t1);
104-
const ShapeRating* b = reinterpret_cast<const ShapeRating *>(t2);
103+
const ShapeRating* a = static_cast<const ShapeRating *>(t1);
104+
const ShapeRating* b = static_cast<const ShapeRating *>(t2);
105105
if (a->rating > b->rating) {
106106
return -1;
107107
} else if (a->rating < b->rating) {

dict/dict.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ void Dict::End() {
370370
int Dict::def_letter_is_okay(void* void_dawg_args,
371371
UNICHAR_ID unichar_id,
372372
bool word_end) const {
373-
DawgArgs *dawg_args = reinterpret_cast<DawgArgs*>(void_dawg_args);
373+
DawgArgs *dawg_args = static_cast<DawgArgs*>(void_dawg_args);
374374

375375
if (dawg_debug_level >= 3) {
376376
tprintf("def_letter_is_okay: current unichar=%s word_end=%d"

dict/permdawg.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void Dict::go_deeper_dawg_fxn(
5353
int char_choice_index, const CHAR_FRAGMENT_INFO *prev_char_frag_info,
5454
bool word_ending, WERD_CHOICE *word, float certainties[], float *limit,
5555
WERD_CHOICE *best_choice, int *attempts_left, void *void_more_args) {
56-
DawgArgs *more_args = reinterpret_cast<DawgArgs*>(void_more_args);
56+
DawgArgs *more_args = static_cast<DawgArgs*>(void_more_args);
5757
word_ending = (char_choice_index == char_choices.size()-1);
5858
int word_index = word->length() - 1;
5959
if (best_choice->rating() < *limit) return;

dict/trie.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ NODE_REF Trie::new_dawg_node() {
281281

282282
// Sort function to sort words by decreasing order of length.
283283
static int sort_strings_by_dec_length(const void* v1, const void* v2) {
284-
const STRING* s1 = reinterpret_cast<const STRING*>(v1);
285-
const STRING* s2 = reinterpret_cast<const STRING*>(v2);
284+
const STRING* s1 = static_cast<const STRING*>(v1);
285+
const STRING* s2 = static_cast<const STRING*>(v2);
286286
return s2->length() - s1->length();
287287
}
288288

lstm/fullyconnected.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ void FullyConnected::Update(float learning_rate, float momentum,
291291
void FullyConnected::CountAlternators(const Network& other, double* same,
292292
double* changed) const {
293293
ASSERT_HOST(other.type() == type_);
294-
const FullyConnected* fc = reinterpret_cast<const FullyConnected*>(&other);
294+
const FullyConnected* fc = static_cast<const FullyConnected*>(&other);
295295
weights_.CountAlternators(fc->weights_, same, changed);
296296
}
297297

0 commit comments

Comments
 (0)