27
27
#include < cstdio>
28
28
#endif
29
29
30
- #define CALLOC LEPT_CALLOC
31
- #define FREE LEPT_FREE
32
-
33
30
#ifdef USE_OPENCL
34
31
35
32
#include " opencl_device_selection.h"
@@ -286,8 +283,6 @@ static const char *findString(const char *contentStart, const char *contentEnd,
286
283
287
284
static ds_status readProFile (const char *fileName, char **content,
288
285
size_t *contentSize) {
289
- size_t size = 0 ;
290
-
291
286
*contentSize = 0 ;
292
287
*content = nullptr ;
293
288
@@ -297,13 +292,9 @@ static ds_status readProFile(const char *fileName, char **content,
297
292
}
298
293
299
294
fseek (input, 0L , SEEK_END);
300
- size = ftell (input);
295
+ size_t size = ftell (input);
301
296
rewind (input);
302
- char *binary = (char *)malloc (size);
303
- if (binary == nullptr ) {
304
- fclose (input);
305
- return DS_FILE_ERROR;
306
- }
297
+ char *binary = new char [size];
307
298
fread (binary, sizeof (char ), size, input);
308
299
fclose (input);
309
300
@@ -320,8 +311,7 @@ static ds_status readProfileFromFile(ds_profile *profile,
320
311
ds_score_deserializer deserializer,
321
312
const char *file) {
322
313
ds_status status = DS_SUCCESS;
323
- char *contentStart = nullptr ;
324
- const char *contentEnd = nullptr ;
314
+ char *contentStart;
325
315
size_t contentSize;
326
316
327
317
if (profile == nullptr ) return DS_INVALID_PROFILE;
@@ -332,7 +322,7 @@ static ds_status readProfileFromFile(ds_profile *profile,
332
322
const char *dataStart;
333
323
const char *dataEnd;
334
324
335
- contentEnd = contentStart + contentSize;
325
+ const char * contentEnd = contentStart + contentSize;
336
326
currentPosition = contentStart;
337
327
338
328
// parse the version string
@@ -485,7 +475,7 @@ static ds_status readProfileFromFile(ds_profile *profile,
485
475
}
486
476
}
487
477
cleanup:
488
- free ( contentStart) ;
478
+ delete[] contentStart;
489
479
return status;
490
480
}
491
481
0 commit comments