Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct the names of shared region functions. #5585

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/argon2_fmt_plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static void init(struct fmt_main *self)
thread_mem = mem_calloc(NUM_THREADS, sizeof(struct argon2_memory));

for (i = 0; i < NUM_THREADS; i++)
init_region_t(&thread_mem[i].region);
init_region(&thread_mem[i].region);
}

static void done(void)
Expand All @@ -164,7 +164,7 @@ static void done(void)
MEM_FREE(crypted);
MEM_FREE(saved_key);
for (i = 0; i < NUM_THREADS; i++)
free_region_t(&thread_mem[i].region);
free_region(&thread_mem[i].region);
MEM_FREE(thread_mem);
}

Expand Down Expand Up @@ -281,8 +281,8 @@ static int allocate(uint8_t **memory, size_t size)
}

if (thread_mem[THREAD_NUMBER].region.aligned_size < size) {
if (free_region_t(&thread_mem[THREAD_NUMBER].region) ||
!alloc_region_t(&thread_mem[THREAD_NUMBER].region, size))
if (free_region(&thread_mem[THREAD_NUMBER].region) ||
!alloc_region(&thread_mem[THREAD_NUMBER].region, size))
goto fail;
}

Expand Down
10 changes: 5 additions & 5 deletions src/armory_fmt_plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static void init(struct fmt_main *self)
memory = mem_alloc(sizeof(*memory) * max_threads);
int i;
for (i = 0; i < max_threads; i++)
init_region_t(&memory[i]);
init_region(&memory[i]);

saved_key = mem_calloc(self->params.max_keys_per_crypt, sizeof(*saved_key));
crypt_out = mem_calloc(self->params.max_keys_per_crypt, sizeof(*crypt_out));
Expand All @@ -134,7 +134,7 @@ static void done(void)
{
int i;
for (i = 0; i < max_threads; i++)
free_region_t(&memory[i]);
free_region(&memory[i]);
MEM_FREE(memory);

MEM_FREE(saved_key);
Expand All @@ -156,7 +156,7 @@ void reset(struct db_main *db)

int i;
for (i = 0; i < max_threads; i++)
free_region_t(&memory[i]);
free_region(&memory[i]);
}

static void *get_salt(char *ciphertext)
Expand Down Expand Up @@ -255,8 +255,8 @@ static int derive_keys(region_t *memory, int index, derived_key *dk)
lut_item *lut = memory->aligned;
size_t bytes_reqd = (size_t)n * sizeof(*lut);
if (!lut || memory->aligned_size < bytes_reqd) {
if (free_region_t(memory) ||
!(lut = alloc_region_t(memory, bytes_reqd)))
if (free_region(memory) ||
!(lut = alloc_region(memory, bytes_reqd)))
return -1;
}

Expand Down
8 changes: 4 additions & 4 deletions src/keepass_fmt_plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static void init(struct fmt_main *self)
any_cracked = 0;

for (i = 0; i < NUM_THREADS; i++)
init_region_t(&thread_mem[i].region);
init_region(&thread_mem[i].region);

Twofish_initialise();
}
Expand All @@ -109,7 +109,7 @@ static void done(void)
MEM_FREE(cracked);
MEM_FREE(keepass_key);
for (i = 0; i < NUM_THREADS; i++)
free_region_t(&thread_mem[i].region);
free_region(&thread_mem[i].region);
MEM_FREE(thread_mem);
}

Expand All @@ -125,8 +125,8 @@ static int allocate(uint8_t **memory, size_t size)
}

if (thread_mem[THREAD_NUMBER].region.aligned_size < size) {
if (free_region_t(&thread_mem[THREAD_NUMBER].region) ||
!alloc_region_t(&thread_mem[THREAD_NUMBER].region, size))
if (free_region(&thread_mem[THREAD_NUMBER].region) ||
!alloc_region(&thread_mem[THREAD_NUMBER].region, size))
goto fail;
}

Expand Down
8 changes: 4 additions & 4 deletions src/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ void alter_endianity_w64(void *_x, unsigned int count) {
#endif

void *
alloc_region_t(region_t * region, size_t size)
alloc_region(region_t * region, size_t size)
{
size_t base_size = size;
void * base, * aligned;
Expand Down Expand Up @@ -702,13 +702,13 @@ alloc_region_t(region_t * region, size_t size)
return aligned;
}

inline void init_region_t(region_t * region)
inline void init_region(region_t * region)
{
region->base = region->aligned = NULL;
region->base_size = region->aligned_size = 0;
}

int free_region_t(region_t * region)
int free_region(region_t * region)
{
if (region->base) {
#ifdef MAP_ANON
Expand All @@ -718,6 +718,6 @@ int free_region_t(region_t * region)
free(region->base);
#endif
}
init_region_t(region);
init_region(region);
return 0;
}
6 changes: 3 additions & 3 deletions src/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ typedef struct {
size_t base_size, aligned_size;
} region_t;

extern void* alloc_region_t(region_t * region, size_t size);
extern void init_region_t(region_t * region);
extern int free_region_t(region_t * region);
extern void* alloc_region(region_t * region, size_t size);
extern void init_region(region_t * region);
extern int free_region(region_t * region);

#endif