Skip to content

Commit 49a8287

Browse files
committed
Use "size_t" instead of "long" for sizes.
1 parent 4074f1e commit 49a8287

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

example/DllLoader/DllLoader.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ void LoadFromFile(void)
4646
FreeLibrary(handle);
4747
}
4848

49-
void* ReadLibrary(long* pSize) {
50-
long read;
49+
void* ReadLibrary(size_t* pSize) {
50+
size_t read;
5151
void* result;
5252
FILE* fp;
5353

@@ -59,8 +59,8 @@ void* ReadLibrary(long* pSize) {
5959
}
6060

6161
fseek(fp, 0, SEEK_END);
62-
*pSize = ftell(fp);
63-
if (*pSize < 0)
62+
*pSize = static_cast<size_t>(ftell(fp));
63+
if (*pSize == 0)
6464
{
6565
fclose(fp);
6666
return NULL;
@@ -75,7 +75,7 @@ void* ReadLibrary(long* pSize) {
7575
fseek(fp, 0, SEEK_SET);
7676
read = fread(result, 1, *pSize, fp);
7777
fclose(fp);
78-
if (read != static_cast<size_t>(*pSize))
78+
if (read != *pSize)
7979
{
8080
free(result);
8181
return NULL;
@@ -87,7 +87,7 @@ void* ReadLibrary(long* pSize) {
8787
void LoadFromMemory(void)
8888
{
8989
void *data;
90-
long size;
90+
size_t size;
9191
HMEMORYMODULE handle;
9292
addNumberProc addNumber;
9393
HMEMORYRSRC resourceInfo;
@@ -195,7 +195,7 @@ void InitFreeFunc(CallList* calls, CustomFreeFunc freeFunc) {
195195
calls->current_free_call = 0;
196196
}
197197

198-
void TestFailingAllocation(void *data, long size) {
198+
void TestFailingAllocation(void *data, size_t size) {
199199
CallList expected_calls;
200200
HMEMORYMODULE handle;
201201

@@ -214,7 +214,7 @@ void TestFailingAllocation(void *data, long size) {
214214
assert(expected_calls.current_free_call == 0);
215215
}
216216

217-
void TestCleanupAfterFailingAllocation(void *data, long size) {
217+
void TestCleanupAfterFailingAllocation(void *data, size_t size) {
218218
CallList expected_calls;
219219
HMEMORYMODULE handle;
220220
int free_calls_after_loading;
@@ -238,7 +238,7 @@ void TestCleanupAfterFailingAllocation(void *data, long size) {
238238
assert(expected_calls.current_free_call == free_calls_after_loading);
239239
}
240240

241-
void TestFreeAfterDefaultAlloc(void *data, long size) {
241+
void TestFreeAfterDefaultAlloc(void *data, size_t size) {
242242
CallList expected_calls;
243243
HMEMORYMODULE handle;
244244
int free_calls_after_loading;
@@ -260,7 +260,7 @@ void TestFreeAfterDefaultAlloc(void *data, long size) {
260260
void TestCustomAllocAndFree(void)
261261
{
262262
void *data;
263-
long size;
263+
size_t size;
264264

265265
data = ReadLibrary(&size);
266266
if (data == NULL)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy