Reviewed uses of reinterpret_cast

This commit is contained in:
Raf Schietekat 2017-05-11 00:40:31 +02:00
parent 3454061334
commit 3983d2f76a
39 changed files with 98 additions and 97 deletions

View File

@ -165,7 +165,7 @@ size_t TessBaseAPI::getOpenCLDevice(void **data) {
#if USE_DEVICE_SELECTION #if USE_DEVICE_SELECTION
ds_device device = OpenclDevice::getDeviceSelection(); ds_device device = OpenclDevice::getDeviceSelection();
if (device.type == DS_DEVICE_OPENCL_DEVICE) { if (device.type == DS_DEVICE_OPENCL_DEVICE) {
*data = reinterpret_cast<void*>(new cl_device_id); *data = new cl_device_id;
memcpy(*data, &device.oclDeviceID, sizeof(cl_device_id)); memcpy(*data, &device.oclDeviceID, sizeof(cl_device_id));
return sizeof(cl_device_id); return sizeof(cl_device_id);
} }

View File

@ -56,24 +56,24 @@ namespace tesseract {
// Utility ColParition sort functions. // Utility ColParition sort functions.
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
static int SortCPByTopReverse(const void* p1, const void* p2) { static int SortCPByTopReverse(const void* p1, const void* p2) {
const ColPartition* cp1 = *reinterpret_cast<ColPartition* const*>(p1); const ColPartition* cp1 = *static_cast<ColPartition* const*>(p1);
const ColPartition* cp2 = *reinterpret_cast<ColPartition* const*>(p2); const ColPartition* cp2 = *static_cast<ColPartition* const*>(p2);
ASSERT_HOST(cp1 != NULL && cp2 != NULL); ASSERT_HOST(cp1 != NULL && cp2 != NULL);
const TBOX &box1(cp1->bounding_box()), &box2(cp2->bounding_box()); const TBOX &box1(cp1->bounding_box()), &box2(cp2->bounding_box());
return box2.top() - box1.top(); return box2.top() - box1.top();
} }
static int SortCPByBottom(const void* p1, const void* p2) { static int SortCPByBottom(const void* p1, const void* p2) {
const ColPartition* cp1 = *reinterpret_cast<ColPartition* const*>(p1); const ColPartition* cp1 = *static_cast<ColPartition* const*>(p1);
const ColPartition* cp2 = *reinterpret_cast<ColPartition* const*>(p2); const ColPartition* cp2 = *static_cast<ColPartition* const*>(p2);
ASSERT_HOST(cp1 != NULL && cp2 != NULL); ASSERT_HOST(cp1 != NULL && cp2 != NULL);
const TBOX &box1(cp1->bounding_box()), &box2(cp2->bounding_box()); const TBOX &box1(cp1->bounding_box()), &box2(cp2->bounding_box());
return box1.bottom() - box2.bottom(); return box1.bottom() - box2.bottom();
} }
static int SortCPByHeight(const void* p1, const void* p2) { static int SortCPByHeight(const void* p1, const void* p2) {
const ColPartition* cp1 = *reinterpret_cast<ColPartition* const*>(p1); const ColPartition* cp1 = *static_cast<ColPartition* const*>(p1);
const ColPartition* cp2 = *reinterpret_cast<ColPartition* const*>(p2); const ColPartition* cp2 = *static_cast<ColPartition* const*>(p2);
ASSERT_HOST(cp1 != NULL && cp2 != NULL); ASSERT_HOST(cp1 != NULL && cp2 != NULL);
const TBOX &box1(cp1->bounding_box()), &box2(cp2->bounding_box()); const TBOX &box1(cp1->bounding_box()), &box2(cp2->bounding_box());
return box1.height() - box2.height(); return box1.height() - box2.height();

View File

@ -184,9 +184,9 @@ void ParamsEditor::GetPrefixes(const char* s, STRING* level_one,
// Compare two VC objects by their name. // Compare two VC objects by their name.
int ParamContent::Compare(const void* v1, const void* v2) { int ParamContent::Compare(const void* v1, const void* v2) {
const ParamContent* one = const ParamContent* one =
*reinterpret_cast<const ParamContent* const *>(v1); *static_cast<const ParamContent* const *>(v1);
const ParamContent* two = const ParamContent* two =
*reinterpret_cast<const ParamContent* const *>(v2); *static_cast<const ParamContent* const *>(v2);
return strcmp(one->GetName(), two->GetName()); return strcmp(one->GetName(), two->GetName());
} }

View File

@ -312,7 +312,7 @@ void ImageThresholder::ThresholdRectToPix(Pix* src_pix,
bool white_result = true; bool white_result = true;
for (int ch = 0; ch < num_channels; ++ch) { for (int ch = 0; ch < num_channels; ++ch) {
int pixel = GET_DATA_BYTE(const_cast<void*>( int pixel = GET_DATA_BYTE(const_cast<void*>(
reinterpret_cast<const void *>(linedata)), static_cast<const void *>(linedata)),
(x + rect_left_) * num_channels + ch); (x + rect_left_) * num_channels + ch);
if (hi_values[ch] >= 0 && if (hi_values[ch] >= 0 &&
(pixel > thresholds[ch]) == (hi_values[ch] == 0)) { (pixel > thresholds[ch]) == (hi_values[ch] == 0)) {

View File

@ -94,7 +94,7 @@ inT16 length //length of loop
pos = startpt; pos = startpt;
stepcount = length; // No. of steps. stepcount = length; // No. of steps.
ASSERT_HOST(length >= 0); ASSERT_HOST(length >= 0);
steps = reinterpret_cast<uinT8*>(alloc_mem(step_mem())); // Get memory. steps = static_cast<uinT8*>(alloc_mem(step_mem())); // Get memory.
memset(steps, 0, step_mem()); memset(steps, 0, step_mem());
lastdir = new_steps[length - 1]; lastdir = new_steps[length - 1];
@ -655,23 +655,23 @@ static void ComputeGradient(const l_uint32* data, int wpl,
int pix_x_y = int pix_x_y =
x < width && y < height x < width && y < height
? GET_DATA_BYTE( ? GET_DATA_BYTE(
const_cast<void*>(reinterpret_cast<const void*>(line)), x) const_cast<void*>(static_cast<const void*>(line)), x)
: 255; : 255;
int pix_x_prevy = int pix_x_prevy =
x < width && y > 0 x < width && y > 0
? GET_DATA_BYTE( ? GET_DATA_BYTE(
const_cast<void*>(reinterpret_cast<const void*>(line - wpl)), x) const_cast<void*>(static_cast<const void*>(line - wpl)), x)
: 255; : 255;
int pix_prevx_prevy = int pix_prevx_prevy =
x > 0 && y > 0 x > 0 && y > 0
? GET_DATA_BYTE( ? GET_DATA_BYTE(
const_cast<void*>(reinterpret_cast<void const*>(line - wpl)), const_cast<void*>(static_cast<void const*>(line - wpl)),
x - 1) x - 1)
: 255; : 255;
int pix_prevx_y = int pix_prevx_y =
x > 0 && y < height x > 0 && y < height
? GET_DATA_BYTE( ? GET_DATA_BYTE(
const_cast<void*>(reinterpret_cast<const void*>(line)), x - 1) const_cast<void*>(static_cast<const void*>(line)), x - 1)
: 255; : 255;
gradient->set_x(pix_x_y + pix_x_prevy - (pix_prevx_y + pix_prevx_prevy)); gradient->set_x(pix_x_y + pix_x_prevy - (pix_prevx_y + pix_prevx_prevy));
gradient->set_y(pix_x_prevy + pix_prevx_prevy - (pix_x_y + pix_prevx_y)); 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,
return false; return false;
const l_uint32* line = data + y * wpl; const l_uint32* line = data + y * wpl;
int pixel1 = GET_DATA_BYTE( int pixel1 = GET_DATA_BYTE(
const_cast<void*>(reinterpret_cast<const void*>(line - wpl)), x); const_cast<void*>(static_cast<const void*>(line - wpl)), x);
int pixel2 = int pixel2 =
GET_DATA_BYTE(const_cast<void*>(reinterpret_cast<const void*>(line)), x); GET_DATA_BYTE(const_cast<void*>(static_cast<const void*>(line)), x);
int diff = (pixel2 - pixel1) * diff_sign; int diff = (pixel2 - pixel1) * diff_sign;
if (diff > *best_diff) { if (diff > *best_diff) {
*best_diff = diff; *best_diff = diff;
@ -712,9 +712,9 @@ static bool EvaluateHorizontalDiff(const l_uint32* line, int diff_sign,
if (x <= 0 || x >= width) if (x <= 0 || x >= width)
return false; return false;
int pixel1 = GET_DATA_BYTE( int pixel1 = GET_DATA_BYTE(
const_cast<void*>(reinterpret_cast<const void*>(line)), x - 1); const_cast<void*>(static_cast<const void*>(line)), x - 1);
int pixel2 = int pixel2 =
GET_DATA_BYTE(const_cast<void*>(reinterpret_cast<const void*>(line)), x); GET_DATA_BYTE(const_cast<void*>(static_cast<const void*>(line)), x);
int diff = (pixel2 - pixel1) * diff_sign; int diff = (pixel2 - pixel1) * diff_sign;
if (diff > *best_diff) { if (diff > *best_diff) {
*best_diff = diff; *best_diff = diff;

View File

@ -112,8 +112,8 @@ void FloatWordFeature::FromWordFeatures(
// Sort function to sort first by x-bucket, then by y. // Sort function to sort first by x-bucket, then by y.
/* static */ /* static */
int FloatWordFeature::SortByXBucket(const void* v1, const void* v2) { int FloatWordFeature::SortByXBucket(const void* v1, const void* v2) {
const FloatWordFeature* f1 = reinterpret_cast<const FloatWordFeature*>(v1); const FloatWordFeature* f1 = static_cast<const FloatWordFeature*>(v1);
const FloatWordFeature* f2 = reinterpret_cast<const FloatWordFeature*>(v2); const FloatWordFeature* f2 = static_cast<const FloatWordFeature*>(v2);
int x_diff = f1->x_bucket - f2->x_bucket; int x_diff = f1->x_bucket - f2->x_bucket;
if (x_diff == 0) return f1->y - f2->y; if (x_diff == 0) return f1->y - f2->y;
return x_diff; return x_diff;
@ -367,7 +367,7 @@ bool ImageData::AddBoxes(const char* box_text) {
// Thread function to call ReCachePages. // Thread function to call ReCachePages.
void* ReCachePagesFunc(void* data) { void* ReCachePagesFunc(void* data) {
DocumentData* document_data = reinterpret_cast<DocumentData*>(data); DocumentData* document_data = static_cast<DocumentData*>(data);
document_data->ReCachePages(); document_data->ReCachePages();
return NULL; return NULL;
} }

View File

@ -38,7 +38,7 @@
class BLOB_CHOICE; class BLOB_CHOICE;
class BLOB_CHOICE_LIST; class BLOB_CHOICE_LIST;
#define NOT_CLASSIFIED reinterpret_cast<BLOB_CHOICE_LIST*>(0) #define NOT_CLASSIFIED static_cast<BLOB_CHOICE_LIST*>(0)
// A generic class to hold a 2-D matrix with entries of type T, but can also // A generic class to hold a 2-D matrix with entries of type T, but can also
// act as a base class for other implementations, such as a triangular or // act as a base class for other implementations, such as a triangular or

View File

@ -162,7 +162,7 @@ void HistogramRect(Pix* src_pix, int channel,
const l_uint32* linedata = srcdata + y * src_wpl; const l_uint32* linedata = srcdata + y * src_wpl;
for (int x = 0; x < width; ++x) { for (int x = 0; x < width; ++x) {
int pixel = GET_DATA_BYTE(const_cast<void*>( int pixel = GET_DATA_BYTE(const_cast<void*>(
reinterpret_cast<const void *>(linedata)), static_cast<const void *>(linedata)),
(x + left) * num_channels + channel); (x + left) * num_channels + channel);
++histogram[pixel]; ++histogram[pixel];
} }

View File

@ -191,9 +191,9 @@ class BLOB_CHOICE: public ELIST_LINK
// Sort function for sorting BLOB_CHOICEs in increasing order of rating. // Sort function for sorting BLOB_CHOICEs in increasing order of rating.
static int SortByRating(const void *p1, const void *p2) { static int SortByRating(const void *p1, const void *p2) {
const BLOB_CHOICE *bc1 = const BLOB_CHOICE *bc1 =
*reinterpret_cast<const BLOB_CHOICE * const *>(p1); *static_cast<const BLOB_CHOICE * const *>(p1);
const BLOB_CHOICE *bc2 = const BLOB_CHOICE *bc2 =
*reinterpret_cast<const BLOB_CHOICE * const *>(p2); *static_cast<const BLOB_CHOICE * const *>(p2);
return (bc1->rating_ < bc2->rating_) ? -1 : 1; return (bc1->rating_ < bc2->rating_) ? -1 : 1;
} }

View File

@ -772,8 +772,8 @@ void swap_entries(void *array, // array of entries
char *ptr2; char *ptr2;
size_t count; // of bytes size_t count; // of bytes
ptr1 = reinterpret_cast<char*>(array) + index1 * size; ptr1 = static_cast<char*>(array) + index1 * size;
ptr2 = reinterpret_cast<char*>(array) + index2 * size; ptr2 = static_cast<char*>(array) + index2 * size;
for (count = 0; count < size; count++) { for (count = 0; count < size; count++) {
tmp = *ptr1; tmp = *ptr1;
*ptr1++ = *ptr2; *ptr1++ = *ptr2;

View File

@ -117,8 +117,8 @@ class C_BLOB:public ELIST_LINK
} }
static int SortByXMiddle(const void *v1, const void *v2) { static int SortByXMiddle(const void *v1, const void *v2) {
const C_BLOB* blob1 = *reinterpret_cast<const C_BLOB* const *>(v1); const C_BLOB* blob1 = *static_cast<const C_BLOB* const *>(v1);
const C_BLOB* blob2 = *reinterpret_cast<const C_BLOB* const *>(v2); const C_BLOB* blob2 = *static_cast<const C_BLOB* const *>(v2);
return blob1->bounding_box().x_middle() - return blob1->bounding_box().x_middle() -
blob2->bounding_box().x_middle(); blob2->bounding_box().x_middle();
} }

View File

@ -121,9 +121,9 @@ class AmbigSpec : public ELIST_LINK {
// in a a sorted AmbigSpec_LIST: [9 1 3], [9 3 4], [9 8], [9, 8 1]. // in a a sorted AmbigSpec_LIST: [9 1 3], [9 3 4], [9 8], [9, 8 1].
static int compare_ambig_specs(const void *spec1, const void *spec2) { static int compare_ambig_specs(const void *spec1, const void *spec2) {
const AmbigSpec *s1 = const AmbigSpec *s1 =
*reinterpret_cast<const AmbigSpec * const *>(spec1); *static_cast<const AmbigSpec * const *>(spec1);
const AmbigSpec *s2 = const AmbigSpec *s2 =
*reinterpret_cast<const AmbigSpec * const *>(spec2); *static_cast<const AmbigSpec * const *>(spec2);
int result = UnicharIdArrayUtils::compare(s1->wrong_ngram, s2->wrong_ngram); int result = UnicharIdArrayUtils::compare(s1->wrong_ngram, s2->wrong_ngram);
if (result != 0) return result; if (result != 0) return result;
return UnicharIdArrayUtils::compare(s1->correct_fragments, return UnicharIdArrayUtils::compare(s1->correct_fragments,

View File

@ -421,8 +421,8 @@ int sort_cmp(const void* t1, const void* t2) {
// return > 0 if t1 > t2 // return > 0 if t1 > t2
template <typename T> template <typename T>
int sort_ptr_cmp(const void* t1, const void* t2) { int sort_ptr_cmp(const void* t1, const void* t2) {
const T* a = *reinterpret_cast<T * const *>(t1); const T* a = *static_cast<T * const *>(t1);
const T* b = *reinterpret_cast<T * const *>(t2); const T* b = *static_cast<T * const *>(t2);
if (*a < *b) { if (*a < *b) {
return -1; return -1;
} else if (*b < *a) { } else if (*b < *a) {

View File

@ -182,7 +182,7 @@ inline int IntCastRounded(double x) {
// Reverse the order of bytes in a n byte quantity for big/little-endian switch. // Reverse the order of bytes in a n byte quantity for big/little-endian switch.
inline void ReverseN(void* ptr, int num_bytes) { inline void ReverseN(void* ptr, int num_bytes) {
char *cptr = reinterpret_cast<char *>(ptr); char *cptr = static_cast<char *>(ptr);
int halfsize = num_bytes / 2; int halfsize = num_bytes / 2;
for (int i = 0; i < halfsize; ++i) { for (int i = 0; i < halfsize; ++i) {
char tmp = cptr[i]; char tmp = cptr[i];

View File

@ -97,7 +97,7 @@ char* TFile::FGets(char* buffer, int buffer_size) {
int TFile::FReadEndian(void* buffer, int size, int count) { int TFile::FReadEndian(void* buffer, int size, int count) {
int num_read = FRead(buffer, size, count); int num_read = FRead(buffer, size, count);
if (swap_) { if (swap_) {
char* char_buffer = reinterpret_cast<char*>(buffer); char* char_buffer = static_cast<char*>(buffer);
for (int i = 0; i < num_read; ++i, char_buffer += size) { for (int i = 0; i < num_read; ++i, char_buffer += size) {
ReverseN(char_buffer, size); ReverseN(char_buffer, size);
} }
@ -109,7 +109,7 @@ int TFile::FRead(void* buffer, int size, int count) {
ASSERT_HOST(!is_writing_); ASSERT_HOST(!is_writing_);
int required_size = size * count; int required_size = size * count;
if (required_size <= 0) return 0; if (required_size <= 0) return 0;
char* char_buffer = reinterpret_cast<char*>(buffer); char* char_buffer = static_cast<char*>(buffer);
if (data_->size() - offset_ < required_size) if (data_->size() - offset_ < required_size)
required_size = data_->size() - offset_; required_size = data_->size() - offset_;
if (required_size > 0 && char_buffer != NULL) if (required_size > 0 && char_buffer != NULL)
@ -150,7 +150,7 @@ int TFile::FWrite(const void* buffer, int size, int count) {
ASSERT_HOST(is_writing_); ASSERT_HOST(is_writing_);
int total = size * count; int total = size * count;
if (total <= 0) return 0; if (total <= 0) return 0;
const char* buf = reinterpret_cast<const char*>(buffer); const char* buf = static_cast<const char*>(buffer);
// This isn't very efficient, but memory is so fast compared to disk // This isn't very efficient, but memory is so fast compared to disk
// that it is relatively unimportant, and very simple. // that it is relatively unimportant, and very simple.
for (int i = 0; i < total; ++i) for (int i = 0; i < total; ++i)

View File

@ -42,14 +42,14 @@ class SortHelper {
}; };
// qsort function to sort by decreasing count. // qsort function to sort by decreasing count.
static int SortPairsByCount(const void* v1, const void* v2) { static int SortPairsByCount(const void* v1, const void* v2) {
const SortPair<T>* p1 = reinterpret_cast<const SortPair<T>*>(v1); const SortPair<T>* p1 = static_cast<const SortPair<T>*>(v1);
const SortPair<T>* p2 = reinterpret_cast<const SortPair<T>*>(v2); const SortPair<T>* p2 = static_cast<const SortPair<T>*>(v2);
return p2->count - p1->count; return p2->count - p1->count;
} }
// qsort function to sort by decreasing value. // qsort function to sort by decreasing value.
static int SortPairsByValue(const void* v1, const void* v2) { static int SortPairsByValue(const void* v1, const void* v2) {
const SortPair<T>* p1 = reinterpret_cast<const SortPair<T>*>(v1); const SortPair<T>* p1 = static_cast<const SortPair<T>*>(v1);
const SortPair<T>* p2 = reinterpret_cast<const SortPair<T>*>(v2); const SortPair<T>* p2 = static_cast<const SortPair<T>*>(v2);
if (p2->value - p1->value < 0) return -1; if (p2->value - p1->value < 0) return -1;
if (p2->value - p1->value > 0) return 1; if (p2->value - p1->value > 0) return 1;
return 0; return 0;

View File

@ -2242,7 +2242,7 @@ void Classify::ShowBestMatchFor(int shape_id,
tprintf("Static Shape ID: %d\n", shape_id); tprintf("Static Shape ID: %d\n", shape_id);
ShowMatchDisplay(); ShowMatchDisplay();
im_.Match(ClassForClassId(PreTrainedTemplates, shape_id), im_.Match(ClassForClassId(PreTrainedTemplates, shape_id),
AllProtosOn, reinterpret_cast<BIT_VECTOR>(&config_mask), AllProtosOn, &config_mask, // TODO: or reinterpret_cast<BIT_VECTOR>(&config_mask) anyway?
num_features, features, &cn_result, num_features, features, &cn_result,
classify_adapt_feature_threshold, classify_adapt_feature_threshold,
matcher_debug_flags, matcher_debug_flags,

View File

@ -1123,9 +1123,9 @@ PROTOTYPE *TestEllipticalProto(CLUSTERER *Clusterer,
if (TotalDims < N + 1 || TotalDims < 2) if (TotalDims < N + 1 || TotalDims < 2)
return NULL; return NULL;
const int kMatrixSize = N * N * sizeof(FLOAT32); const int kMatrixSize = N * N * sizeof(FLOAT32);
FLOAT32* Covariance = reinterpret_cast<FLOAT32 *>(Emalloc(kMatrixSize)); FLOAT32* Covariance = static_cast<FLOAT32 *>(Emalloc(kMatrixSize));
FLOAT32* Inverse = reinterpret_cast<FLOAT32 *>(Emalloc(kMatrixSize)); FLOAT32* Inverse = static_cast<FLOAT32 *>(Emalloc(kMatrixSize));
FLOAT32* Delta = reinterpret_cast<FLOAT32*>(Emalloc(N * sizeof(FLOAT32))); FLOAT32* Delta = static_cast<FLOAT32*>(Emalloc(N * sizeof(FLOAT32)));
// Compute a new covariance matrix that only uses essential features. // Compute a new covariance matrix that only uses essential features.
for (int i = 0; i < N; ++i) { for (int i = 0; i < N; ++i) {
int row_offset = i * N; int row_offset = i * N;
@ -1749,13 +1749,13 @@ BUCKETS *MakeBuckets(DISTRIBUTION Distribution,
BOOL8 Symmetrical; BOOL8 Symmetrical;
// allocate memory needed for data structure // allocate memory needed for data structure
Buckets = reinterpret_cast<BUCKETS*>(Emalloc(sizeof(BUCKETS))); Buckets = static_cast<BUCKETS*>(Emalloc(sizeof(BUCKETS)));
Buckets->NumberOfBuckets = OptimumNumberOfBuckets(SampleCount); Buckets->NumberOfBuckets = OptimumNumberOfBuckets(SampleCount);
Buckets->SampleCount = SampleCount; Buckets->SampleCount = SampleCount;
Buckets->Confidence = Confidence; Buckets->Confidence = Confidence;
Buckets->Count = reinterpret_cast<uinT32*>( Buckets->Count = static_cast<uinT32*>(
Emalloc(Buckets->NumberOfBuckets * sizeof(uinT32))); Emalloc(Buckets->NumberOfBuckets * sizeof(uinT32)));
Buckets->ExpectedCount = reinterpret_cast<FLOAT32*>( Buckets->ExpectedCount = static_cast<FLOAT32*>(
Emalloc(Buckets->NumberOfBuckets * sizeof(FLOAT32))); Emalloc(Buckets->NumberOfBuckets * sizeof(FLOAT32)));
// initialize simple fields // initialize simple fields

View File

@ -227,7 +227,7 @@ FLOAT32 *ReadNFloats(TFile *fp, uinT16 N, FLOAT32 Buffer[]) {
bool needs_free = false; bool needs_free = false;
if (Buffer == NULL) { if (Buffer == NULL) {
Buffer = reinterpret_cast<FLOAT32*>(Emalloc(N * sizeof(FLOAT32))); Buffer = static_cast<FLOAT32*>(Emalloc(N * sizeof(FLOAT32)));
needs_free = true; needs_free = true;
} }

View File

@ -79,8 +79,8 @@ bool UnicharAndFonts::DeSerialize(TFile* fp) {
// Sort function to sort a pair of UnicharAndFonts by unichar_id. // Sort function to sort a pair of UnicharAndFonts by unichar_id.
int UnicharAndFonts::SortByUnicharId(const void* v1, const void* v2) { int UnicharAndFonts::SortByUnicharId(const void* v1, const void* v2) {
const UnicharAndFonts* p1 = reinterpret_cast<const UnicharAndFonts*>(v1); const UnicharAndFonts* p1 = static_cast<const UnicharAndFonts*>(v1);
const UnicharAndFonts* p2 = reinterpret_cast<const UnicharAndFonts*>(v2); const UnicharAndFonts* p2 = static_cast<const UnicharAndFonts*>(v2);
return p1->unichar_id - p2->unichar_id; return p1->unichar_id - p2->unichar_id;
} }

View File

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

View File

@ -370,7 +370,7 @@ void Dict::End() {
int Dict::def_letter_is_okay(void* void_dawg_args, int Dict::def_letter_is_okay(void* void_dawg_args,
UNICHAR_ID unichar_id, UNICHAR_ID unichar_id,
bool word_end) const { bool word_end) const {
DawgArgs *dawg_args = reinterpret_cast<DawgArgs*>(void_dawg_args); DawgArgs *dawg_args = static_cast<DawgArgs*>(void_dawg_args);
if (dawg_debug_level >= 3) { if (dawg_debug_level >= 3) {
tprintf("def_letter_is_okay: current unichar=%s word_end=%d" tprintf("def_letter_is_okay: current unichar=%s word_end=%d"

View File

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

View File

@ -281,8 +281,8 @@ NODE_REF Trie::new_dawg_node() {
// Sort function to sort words by decreasing order of length. // Sort function to sort words by decreasing order of length.
static int sort_strings_by_dec_length(const void* v1, const void* v2) { static int sort_strings_by_dec_length(const void* v1, const void* v2) {
const STRING* s1 = reinterpret_cast<const STRING*>(v1); const STRING* s1 = static_cast<const STRING*>(v1);
const STRING* s2 = reinterpret_cast<const STRING*>(v2); const STRING* s2 = static_cast<const STRING*>(v2);
return s2->length() - s1->length(); return s2->length() - s1->length();
} }

View File

@ -291,7 +291,7 @@ void FullyConnected::Update(float learning_rate, float momentum,
void FullyConnected::CountAlternators(const Network& other, double* same, void FullyConnected::CountAlternators(const Network& other, double* same,
double* changed) const { double* changed) const {
ASSERT_HOST(other.type() == type_); ASSERT_HOST(other.type() == type_);
const FullyConnected* fc = reinterpret_cast<const FullyConnected*>(&other); const FullyConnected* fc = static_cast<const FullyConnected*>(&other);
weights_.CountAlternators(fc->weights_, same, changed); weights_.CountAlternators(fc->weights_, same, changed);
} }

View File

@ -198,7 +198,7 @@ bool LSTM::DeSerialize(TFile* fp) {
} }
delete softmax_; delete softmax_;
if (type_ == NT_LSTM_SOFTMAX || type_ == NT_LSTM_SOFTMAX_ENCODED) { if (type_ == NT_LSTM_SOFTMAX || type_ == NT_LSTM_SOFTMAX_ENCODED) {
softmax_ = reinterpret_cast<FullyConnected*>(Network::CreateFromFile(fp)); softmax_ = static_cast<FullyConnected*>(Network::CreateFromFile(fp));
if (softmax_ == nullptr) return false; if (softmax_ == nullptr) return false;
} else { } else {
softmax_ = nullptr; softmax_ = nullptr;
@ -651,7 +651,7 @@ void LSTM::Update(float learning_rate, float momentum, int num_samples) {
void LSTM::CountAlternators(const Network& other, double* same, void LSTM::CountAlternators(const Network& other, double* same,
double* changed) const { double* changed) const {
ASSERT_HOST(other.type() == type_); ASSERT_HOST(other.type() == type_);
const LSTM* lstm = reinterpret_cast<const LSTM*>(&other); const LSTM* lstm = static_cast<const LSTM*>(&other);
for (int w = 0; w < WT_COUNT; ++w) { for (int w = 0; w < WT_COUNT; ++w) {
if (w == GFS && !Is2D()) continue; if (w == GFS && !Is2D()) continue;
gate_weights_[w].CountAlternators(lstm->gate_weights_[w], same, changed); gate_weights_[w].CountAlternators(lstm->gate_weights_[w], same, changed);

View File

@ -95,7 +95,7 @@ class LSTMRecognizer {
// to access a specific layer. // to access a specific layer.
GenericVector<STRING> EnumerateLayers() const { GenericVector<STRING> EnumerateLayers() const {
ASSERT_HOST(network_ != NULL && network_->type() == NT_SERIES); ASSERT_HOST(network_ != NULL && network_->type() == NT_SERIES);
Series* series = reinterpret_cast<Series*>(network_); Series* series = static_cast<Series*>(network_);
GenericVector<STRING> layers; GenericVector<STRING> layers;
series->EnumerateLayers(NULL, &layers); series->EnumerateLayers(NULL, &layers);
return layers; return layers;
@ -104,7 +104,7 @@ class LSTMRecognizer {
Network* GetLayer(const STRING& id) const { Network* GetLayer(const STRING& id) const {
ASSERT_HOST(network_ != NULL && network_->type() == NT_SERIES); ASSERT_HOST(network_ != NULL && network_->type() == NT_SERIES);
ASSERT_HOST(id.length() > 1 && id[0] == ':'); ASSERT_HOST(id.length() > 1 && id[0] == ':');
Series* series = reinterpret_cast<Series*>(network_); Series* series = static_cast<Series*>(network_);
return series->GetLayer(&id[1]); return series->GetLayer(&id[1]);
} }
// Returns the learning rate of the layer from its id. // Returns the learning rate of the layer from its id.
@ -112,7 +112,7 @@ class LSTMRecognizer {
ASSERT_HOST(network_ != NULL && network_->type() == NT_SERIES); ASSERT_HOST(network_ != NULL && network_->type() == NT_SERIES);
if (network_->TestFlag(NF_LAYER_SPECIFIC_LR)) { if (network_->TestFlag(NF_LAYER_SPECIFIC_LR)) {
ASSERT_HOST(id.length() > 1 && id[0] == ':'); ASSERT_HOST(id.length() > 1 && id[0] == ':');
Series* series = reinterpret_cast<Series*>(network_); Series* series = static_cast<Series*>(network_);
return series->LayerLearningRate(&id[1]); return series->LayerLearningRate(&id[1]);
} else { } else {
return learning_rate_; return learning_rate_;
@ -133,7 +133,7 @@ class LSTMRecognizer {
void ScaleLayerLearningRate(const STRING& id, double factor) { void ScaleLayerLearningRate(const STRING& id, double factor) {
ASSERT_HOST(network_ != NULL && network_->type() == NT_SERIES); ASSERT_HOST(network_ != NULL && network_->type() == NT_SERIES);
ASSERT_HOST(id.length() > 1 && id[0] == ':'); ASSERT_HOST(id.length() > 1 && id[0] == ':');
Series* series = reinterpret_cast<Series*>(network_); Series* series = static_cast<Series*>(network_);
series->ScaleLayerLearningRate(&id[1], factor); series->ScaleLayerLearningRate(&id[1], factor);
} }

View File

@ -52,7 +52,7 @@ bool NetworkBuilder::InitNetwork(int num_outputs, STRING network_spec,
if (append_index >= 0) { if (append_index >= 0) {
// Split the current network after the given append_index. // Split the current network after the given append_index.
ASSERT_HOST(*network != NULL && (*network)->type() == NT_SERIES); ASSERT_HOST(*network != NULL && (*network)->type() == NT_SERIES);
Series* series = reinterpret_cast<Series*>(*network); Series* series = static_cast<Series*>(*network);
Series* top_series = NULL; Series* top_series = NULL;
series->SplitAt(append_index, &bottom_series, &top_series); series->SplitAt(append_index, &bottom_series, &top_series);
if (bottom_series == NULL || top_series == NULL) { if (bottom_series == NULL || top_series == NULL) {

View File

@ -136,7 +136,7 @@ void Plumbing::EnumerateLayers(const STRING* prefix,
if (prefix) layer_name = *prefix; if (prefix) layer_name = *prefix;
layer_name.add_str_int(":", i); layer_name.add_str_int(":", i);
if (stack_[i]->IsPlumbingType()) { if (stack_[i]->IsPlumbingType()) {
Plumbing* plumbing = reinterpret_cast<Plumbing*>(stack_[i]); Plumbing* plumbing = static_cast<Plumbing*>(stack_[i]);
plumbing->EnumerateLayers(&layer_name, layers); plumbing->EnumerateLayers(&layer_name, layers);
} else { } else {
layers->push_back(layer_name); layers->push_back(layer_name);
@ -150,7 +150,7 @@ Network* Plumbing::GetLayer(const char* id) const {
int index = strtol(id, &next_id, 10); int index = strtol(id, &next_id, 10);
if (index < 0 || index >= stack_.size()) return NULL; if (index < 0 || index >= stack_.size()) return NULL;
if (stack_[index]->IsPlumbingType()) { if (stack_[index]->IsPlumbingType()) {
Plumbing* plumbing = reinterpret_cast<Plumbing*>(stack_[index]); Plumbing* plumbing = static_cast<Plumbing*>(stack_[index]);
ASSERT_HOST(*next_id == ':'); ASSERT_HOST(*next_id == ':');
return plumbing->GetLayer(next_id + 1); return plumbing->GetLayer(next_id + 1);
} }
@ -163,7 +163,7 @@ float* Plumbing::LayerLearningRatePtr(const char* id) const {
int index = strtol(id, &next_id, 10); int index = strtol(id, &next_id, 10);
if (index < 0 || index >= stack_.size()) return NULL; if (index < 0 || index >= stack_.size()) return NULL;
if (stack_[index]->IsPlumbingType()) { if (stack_[index]->IsPlumbingType()) {
Plumbing* plumbing = reinterpret_cast<Plumbing*>(stack_[index]); Plumbing* plumbing = static_cast<Plumbing*>(stack_[index]);
ASSERT_HOST(*next_id == ':'); ASSERT_HOST(*next_id == ':');
return plumbing->LayerLearningRatePtr(next_id + 1); return plumbing->LayerLearningRatePtr(next_id + 1);
} }
@ -227,7 +227,7 @@ void Plumbing::Update(float learning_rate, float momentum, int num_samples) {
void Plumbing::CountAlternators(const Network& other, double* same, void Plumbing::CountAlternators(const Network& other, double* same,
double* changed) const { double* changed) const {
ASSERT_HOST(other.type() == type_); ASSERT_HOST(other.type() == type_);
const Plumbing* plumbing = reinterpret_cast<const Plumbing*>(&other); const Plumbing* plumbing = static_cast<const Plumbing*>(&other);
ASSERT_HOST(plumbing->stack_.size() == stack_.size()); ASSERT_HOST(plumbing->stack_.size() == stack_.size());
for (int i = 0; i < stack_.size(); ++i) for (int i = 0; i < stack_.size(); ++i)
stack_[i]->CountAlternators(*plumbing->stack_[i], same, changed); stack_[i]->CountAlternators(*plumbing->stack_[i], same, changed);

View File

@ -157,7 +157,7 @@ void Series::SplitAt(int last_start, Series** start, Series** end) {
for (int s = 0; s <= last_start; ++s) { for (int s = 0; s <= last_start; ++s) {
if (s + 1 == stack_.size() && stack_[s]->type() == NT_SOFTMAX) { if (s + 1 == stack_.size() && stack_[s]->type() == NT_SOFTMAX) {
// Change the softmax to a tanh. // Change the softmax to a tanh.
FullyConnected* fc = reinterpret_cast<FullyConnected*>(stack_[s]); FullyConnected* fc = static_cast<FullyConnected*>(stack_[s]);
fc->ChangeType(NT_TANH); fc->ChangeType(NT_TANH);
} }
master_series->AddToStack(stack_[s]); master_series->AddToStack(stack_[s]);
@ -176,7 +176,7 @@ void Series::SplitAt(int last_start, Series** start, Series** end) {
// deleting it. // deleting it.
void Series::AppendSeries(Network* src) { void Series::AppendSeries(Network* src) {
ASSERT_HOST(src->type() == NT_SERIES); ASSERT_HOST(src->type() == NT_SERIES);
Series* src_series = reinterpret_cast<Series*>(src); Series* src_series = static_cast<Series*>(src);
for (int s = 0; s < src_series->stack_.size(); ++s) { for (int s = 0; s < src_series->stack_.size(); ++s) {
AddToStack(src_series->stack_[s]); AddToStack(src_series->stack_[s]);
src_series->stack_[s] = NULL; src_series->stack_[s] = NULL;

View File

@ -372,8 +372,8 @@ template<class BBC, class BBC_CLIST, class BBC_C_IT> class GridSearch {
template<class BBC> template<class BBC>
int SortByBoxLeft(const void* void1, const void* void2) { int SortByBoxLeft(const void* void1, const void* void2) {
// The void*s are actually doubly indirected, so get rid of one level. // The void*s are actually doubly indirected, so get rid of one level.
const BBC* p1 = *reinterpret_cast<const BBC* const *>(void1); const BBC* p1 = *static_cast<const BBC* const *>(void1);
const BBC* p2 = *reinterpret_cast<const BBC* const *>(void2); const BBC* p2 = *static_cast<const BBC* const *>(void2);
int result = p1->bounding_box().left() - p2->bounding_box().left(); int result = p1->bounding_box().left() - p2->bounding_box().left();
if (result != 0) if (result != 0)
return result; return result;
@ -390,8 +390,8 @@ int SortByBoxLeft(const void* void1, const void* void2) {
template<class BBC> template<class BBC>
int SortRightToLeft(const void* void1, const void* void2) { int SortRightToLeft(const void* void1, const void* void2) {
// The void*s are actually doubly indirected, so get rid of one level. // The void*s are actually doubly indirected, so get rid of one level.
const BBC* p1 = *reinterpret_cast<const BBC* const *>(void1); const BBC* p1 = *static_cast<const BBC* const *>(void1);
const BBC* p2 = *reinterpret_cast<const BBC* const *>(void2); const BBC* p2 = *static_cast<const BBC* const *>(void2);
int result = p2->bounding_box().right() - p1->bounding_box().right(); int result = p2->bounding_box().right() - p1->bounding_box().right();
if (result != 0) if (result != 0)
return result; return result;
@ -408,8 +408,8 @@ int SortRightToLeft(const void* void1, const void* void2) {
template<class BBC> template<class BBC>
int SortByBoxBottom(const void* void1, const void* void2) { int SortByBoxBottom(const void* void1, const void* void2) {
// The void*s are actually doubly indirected, so get rid of one level. // The void*s are actually doubly indirected, so get rid of one level.
const BBC* p1 = *reinterpret_cast<const BBC* const *>(void1); const BBC* p1 = *static_cast<const BBC* const *>(void1);
const BBC* p2 = *reinterpret_cast<const BBC* const *>(void2); const BBC* p2 = *static_cast<const BBC* const *>(void2);
int result = p1->bounding_box().bottom() - p2->bounding_box().bottom(); int result = p1->bounding_box().bottom() - p2->bounding_box().bottom();
if (result != 0) if (result != 0)
return result; return result;

View File

@ -91,8 +91,8 @@ class SimpleStats {
private: private:
static int float_compare(const void* a, const void* b) { static int float_compare(const void* a, const void* b) {
const float* f_a = reinterpret_cast<const float*>(a); const float* f_a = static_cast<const float*>(a);
const float* f_b = reinterpret_cast<const float*>(b); const float* f_b = static_cast<const float*>(b);
return (*f_a > *f_b) ? 1 : ((*f_a < *f_b) ? -1 : 0); return (*f_a > *f_b) ? 1 : ((*f_a < *f_b) ? -1 : 0);
} }
@ -159,8 +159,8 @@ class LocalCorrelation {
private: private:
static int float_pair_compare(const void* a, const void* b) { static int float_pair_compare(const void* a, const void* b) {
const float_pair* f_a = reinterpret_cast<const float_pair*>(a); const float_pair* f_a = static_cast<const float_pair*>(a);
const float_pair* f_b = reinterpret_cast<const float_pair*>(b); const float_pair* f_b = static_cast<const float_pair*>(b);
return (f_a->x > f_b->x) ? 1 : ((f_a->x < f_b->x) ? -1 : 0); return (f_a->x > f_b->x) ? 1 : ((f_a->x < f_b->x) ? -1 : 0);
} }

View File

@ -707,9 +707,9 @@ class ColPartition : public ELIST2_LINK {
// Sort function to sort by bounding box. // Sort function to sort by bounding box.
static int SortByBBox(const void* p1, const void* p2) { static int SortByBBox(const void* p1, const void* p2) {
const ColPartition* part1 = const ColPartition* part1 =
*reinterpret_cast<const ColPartition* const*>(p1); *static_cast<const ColPartition* const*>(p1);
const ColPartition* part2 = const ColPartition* part2 =
*reinterpret_cast<const ColPartition* const*>(p2); *static_cast<const ColPartition* const*>(p2);
int mid_y1 = part1->bounding_box_.y_middle(); int mid_y1 = part1->bounding_box_.y_middle();
int mid_y2 = part2->bounding_box_.y_middle(); int mid_y2 = part2->bounding_box_.y_middle();
if ((part2->bounding_box_.bottom() <= mid_y1 && if ((part2->bounding_box_.bottom() <= mid_y1 &&

View File

@ -292,8 +292,8 @@ class TabVector : public ELIST2_LINK {
// Sort function for E2LIST::sort to sort by sort_key_. // Sort function for E2LIST::sort to sort by sort_key_.
static int SortVectorsByKey(const void* v1, const void* v2) { static int SortVectorsByKey(const void* v1, const void* v2) {
const TabVector* tv1 = *reinterpret_cast<const TabVector* const *>(v1); const TabVector* tv1 = *static_cast<const TabVector* const *>(v1);
const TabVector* tv2 = *reinterpret_cast<const TabVector* const *>(v2); const TabVector* tv2 = *static_cast<const TabVector* const *>(v2);
return tv1->sort_key_ - tv2->sort_key_; return tv1->sort_key_ - tv2->sort_key_;
} }

View File

@ -26,6 +26,7 @@
#include "params.h" #include "params.h"
#include "strngs.h" #include "strngs.h"
#include "tessclassifier.h" #include "tessclassifier.h"
#include "tesseractclass.h"
STRING_PARAM_FLAG(classifier, "", "Classifier to test"); STRING_PARAM_FLAG(classifier, "", "Classifier to test");
STRING_PARAM_FLAG(lang, "eng", "Language to test"); STRING_PARAM_FLAG(lang, "eng", "Language to test");
@ -70,7 +71,7 @@ static tesseract::ShapeClassifier* InitializeClassifier(
return nullptr; return nullptr;
} }
tesseract = const_cast<tesseract::Tesseract*>((*api)->tesseract()); tesseract = const_cast<tesseract::Tesseract*>((*api)->tesseract());
classify = reinterpret_cast<tesseract::Classify*>(tesseract); classify = static_cast<tesseract::Classify*>(tesseract);
if (classify->shape_table() == nullptr) { if (classify->shape_table() == nullptr) {
fprintf(stderr, "Tesseract must contain a ShapeTable!\n"); fprintf(stderr, "Tesseract must contain a ShapeTable!\n");
return nullptr; return nullptr;

View File

@ -119,7 +119,7 @@ STRING LSTMTester::RunEvalSync(int iteration, const double* training_errors,
// it will call UnlockRunning to release the lock after RunEvalSync completes. // it will call UnlockRunning to release the lock after RunEvalSync completes.
/* static */ /* static */
void* LSTMTester::ThreadFunc(void* lstmtester_void) { void* LSTMTester::ThreadFunc(void* lstmtester_void) {
LSTMTester* lstmtester = reinterpret_cast<LSTMTester*>(lstmtester_void); LSTMTester* lstmtester = static_cast<LSTMTester*>(lstmtester_void);
lstmtester->test_result_ = lstmtester->RunEvalSync( lstmtester->test_result_ = lstmtester->RunEvalSync(
lstmtester->test_iteration_, lstmtester->test_training_errors_, lstmtester->test_iteration_, lstmtester->test_training_errors_,
lstmtester->test_model_data_, lstmtester->test_training_stage_); lstmtester->test_model_data_, lstmtester->test_training_stage_);

View File

@ -322,7 +322,7 @@ void ScrollView::Initialize(const char* name, int x_pos, int y_pos, int x_size,
/// Sits and waits for events on this window. /// Sits and waits for events on this window.
void* ScrollView::StartEventHandler(void* a) { void* ScrollView::StartEventHandler(void* a) {
ScrollView* sv = reinterpret_cast<ScrollView*>(a); ScrollView* sv = static_cast<ScrollView*>(a);
SVEvent* new_event; SVEvent* new_event;
do { do {

View File

@ -125,9 +125,9 @@ struct ViterbiStateEntry : public ELIST_LINK {
/// non-increasing order of costs. /// non-increasing order of costs.
static int Compare(const void *e1, const void *e2) { static int Compare(const void *e1, const void *e2) {
const ViterbiStateEntry *ve1 = const ViterbiStateEntry *ve1 =
*reinterpret_cast<const ViterbiStateEntry * const *>(e1); *static_cast<const ViterbiStateEntry * const *>(e1);
const ViterbiStateEntry *ve2 = const ViterbiStateEntry *ve2 =
*reinterpret_cast<const ViterbiStateEntry * const *>(e2); *static_cast<const ViterbiStateEntry * const *>(e2);
return (ve1->cost < ve2->cost) ? -1 : 1; return (ve1->cost < ve2->cost) ? -1 : 1;
} }
inline bool Consistent() const { inline bool Consistent() const {

View File

@ -75,16 +75,16 @@ BLOB_CHOICE_LIST *Wordrec::classify_piece(const GenericVector<SEAM*>& seams,
template<class BLOB_CHOICE> template<class BLOB_CHOICE>
int SortByUnicharID(const void *void1, const void *void2) { int SortByUnicharID(const void *void1, const void *void2) {
const BLOB_CHOICE *p1 = *reinterpret_cast<const BLOB_CHOICE * const *>(void1); const BLOB_CHOICE *p1 = *static_cast<const BLOB_CHOICE * const *>(void1);
const BLOB_CHOICE *p2 = *reinterpret_cast<const BLOB_CHOICE * const *>(void2); const BLOB_CHOICE *p2 = *static_cast<const BLOB_CHOICE * const *>(void2);
return p1->unichar_id() - p2->unichar_id(); return p1->unichar_id() - p2->unichar_id();
} }
template<class BLOB_CHOICE> template<class BLOB_CHOICE>
int SortByRating(const void *void1, const void *void2) { int SortByRating(const void *void1, const void *void2) {
const BLOB_CHOICE *p1 = *reinterpret_cast<const BLOB_CHOICE * const *>(void1); const BLOB_CHOICE *p1 = *static_cast<const BLOB_CHOICE * const *>(void1);
const BLOB_CHOICE *p2 = *reinterpret_cast<const BLOB_CHOICE * const *>(void2); const BLOB_CHOICE *p2 = *static_cast<const BLOB_CHOICE * const *>(void2);
if (p1->rating() < p2->rating()) if (p1->rating() < p2->rating())
return 1; return 1;