Skip to content

Commit

Permalink
Merge pull request #1973 from AsparagusEduardo/_pret/pr2/braces
Browse files Browse the repository at this point in the history
Fixed braces style
  • Loading branch information
GriffinRichards authored Jan 19, 2024
2 parents 6c96641 + 8cab1b7 commit 1eadbc3
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 35 deletions.
34 changes: 23 additions & 11 deletions gflib/malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,24 @@ void *AllocInternal(void *heapStart, u32 size)
if (size & 3)
size = 4 * ((size / 4) + 1);

for (;;) {
for (;;)
{
// Loop through the blocks looking for unused block that's big enough.

if (!pos->flag) {
if (!pos->flag)
{
foundBlockSize = pos->size;

if (foundBlockSize >= size) {
if (foundBlockSize - size < 2 * sizeof(struct MemBlock)) {
if (foundBlockSize >= size)
{
if (foundBlockSize - size < 2 * sizeof(struct MemBlock))
{
// The block isn't much bigger than the requested size,
// so just use it.
pos->flag = TRUE;
} else {
}
else
{
// The block is significantly bigger than the requested
// size, so split the rest into a separate block.
foundBlockSize -= sizeof(struct MemBlock);
Expand Down Expand Up @@ -98,15 +104,18 @@ void *AllocInternal(void *heapStart, u32 size)

void FreeInternal(void *heapStart, void *pointer)
{
if (pointer) {
if (pointer)
{
struct MemBlock *head = (struct MemBlock *)heapStart;
struct MemBlock *block = (struct MemBlock *)((u8 *)pointer - sizeof(struct MemBlock));
block->flag = FALSE;

// If the freed block isn't the last one, merge with the next block
// if it's not in use.
if (block->next != head) {
if (!block->next->flag) {
if (block->next != head)
{
if (!block->next->flag)
{
block->size += sizeof(struct MemBlock) + block->next->size;
block->next->magic = 0;
block->next = block->next->next;
Expand All @@ -117,8 +126,10 @@ void FreeInternal(void *heapStart, void *pointer)

// If the freed block isn't the first one, merge with the previous block
// if it's not in use.
if (block != head) {
if (!block->prev->flag) {
if (block != head)
{
if (!block->prev->flag)
{
block->prev->next = block->next;

if (block->next != head)
Expand All @@ -135,7 +146,8 @@ void *AllocZeroedInternal(void *heapStart, u32 size)
{
void *mem = AllocInternal(heapStart, size);

if (mem != NULL) {
if (mem != NULL)
{
if (size & 3)
size = 4 * ((size / 4) + 1);

Expand Down
6 changes: 4 additions & 2 deletions src/battle_anim_ghost.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,11 +628,13 @@ static void AnimTask_SpiteTargetShadow_Step1(u8 taskId)
task->data[3] = 16;
task->data[13] = GetAnimBattlerSpriteId(ANIM_TARGET);
task->data[4] = OBJ_PLTT_ID2(gSprites[task->data[13]].oam.paletteNum);
if (position == 1) {
if (position == 1)
{
u16 mask = DISPCNT_BG1_ON;
mask2 = mask;
}
else {
else
{
u16 mask = DISPCNT_BG2_ON;
mask2 = mask;
}
Expand Down
3 changes: 2 additions & 1 deletion src/berry_blender.c
Original file line number Diff line number Diff line change
Expand Up @@ -2050,7 +2050,8 @@ static void UpdateSpeedFromHit(u16 cmd)
switch (cmd)
{
case LINKCMD_BLENDER_SCORE_BEST:
if (sBerryBlender->speed < 1500) {
if (sBerryBlender->speed < 1500)
{
sBerryBlender->speed += (384 / sNumPlayersToSpeedDivisor[sBerryBlender->numPlayers]);
}
else
Expand Down
3 changes: 2 additions & 1 deletion src/contest_effect.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ static void ContestEffect_StartleFrontMon(void)
u8 idx = 0;
u8 a = eContestAppealResults.contestant;

if (eContestAppealResults.turnOrder[a] != 0) {
if (eContestAppealResults.turnOrder[a] != 0)
{
int i;

for (i = 0; i < CONTESTANT_COUNT; i++)
Expand Down
15 changes: 10 additions & 5 deletions src/decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ static void UNUSED StitchObjectsOn8x8Canvas(s32 object_size, s32 object_count, u
// While the remaining space will be filled with actual data
if (object_size == 6)
{
for (k = 0; k < 256; k++) {
for (k = 0; k < 256; k++)
{
*dest = 0;
dest++;
}
Expand All @@ -224,22 +225,25 @@ static void UNUSED StitchObjectsOn8x8Canvas(s32 object_size, s32 object_count, u
{
if (object_size == 6)
{
for (k = 0; k < 32; k++) {
for (k = 0; k < 32; k++)
{
*dest = 0;
dest++;
}
}

// Copy tile data
for (k = 0; k < 32 * object_size; k++) {
for (k = 0; k < 32 * object_size; k++)
{
*dest = *src;
src++;
dest++;
}

if (object_size == 6)
{
for (k = 0; k < 32; k++) {
for (k = 0; k < 32; k++)
{
*dest = 0;
dest++;
}
Expand All @@ -248,7 +252,8 @@ static void UNUSED StitchObjectsOn8x8Canvas(s32 object_size, s32 object_count, u

if (object_size == 6)
{
for (k = 0; k < 256; k++) {
for (k = 0; k < 256; k++)
{
*dest = 0;
dest++;
}
Expand Down
6 changes: 4 additions & 2 deletions src/decoration.c
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,8 @@ static void DecorationItemsMenuAction_AttemptPlace(u8 taskId)
else
{
ConvertIntToDecimalStringN(gStringVar1, sDecorationContext.size, STR_CONV_MODE_RIGHT_ALIGN, 2);
if (sDecorationContext.isPlayerRoom == FALSE) {
if (sDecorationContext.isPlayerRoom == FALSE)
{
StringExpandPlaceholders(gStringVar4, gText_NoMoreDecorations);
}
else
Expand Down Expand Up @@ -2254,7 +2255,8 @@ static void Task_PutAwayDecoration(u8 taskId)
gTasks[taskId].tState = 1;
break;
case 1:
if (!gPaletteFade.active) {
if (!gPaletteFade.active)
{
DrawWholeMapView();
ScriptContext_SetupScript(SecretBase_EventScript_PutAwayDecoration);
ClearDialogWindowAndFrame(0, TRUE);
Expand Down
21 changes: 14 additions & 7 deletions src/dodrio_berry_picking.c
Original file line number Diff line number Diff line change
Expand Up @@ -1091,32 +1091,39 @@ static void InitResults_Member(void)
{
u8 i;

switch (sGame->state) {
switch (sGame->state)
{
case 0:
if (SendBlock(0, sGame->berryResults[sGame->timer], sizeof(sGame->berryResults))) {
if (SendBlock(0, sGame->berryResults[sGame->timer], sizeof(sGame->berryResults)))
{
sGame->playersReceived = 0;
sGame->state++;
}
break;
case 1:
if (IsLinkTaskFinished()) {
if (IsLinkTaskFinished())
{
sGame->state++;
}
break;
case 2:
if (AllLinkBlocksReceived()) {
for (i = 0; i < sGame->numPlayers; i++) {
if (AllLinkBlocksReceived())
{
for (i = 0; i < sGame->numPlayers; i++)
{
memcpy(sGame->berryResults, gBlockRecvBuffer, sizeof(sGame->berryResults));
sGame->playersReceived = sGame->numPlayers;
}
}
if (sGame->playersReceived >= sGame->numPlayers) {
if (sGame->playersReceived >= sGame->numPlayers)
{
sGame->timer++;
sGame->state++;
}
break;
default:
if (WaitFanfare(TRUE)) {
if (WaitFanfare(TRUE))
{
sGame->maxBerriesPickedInRow = sGame->berryResults[sGame->multiplayerId][BERRY_IN_ROW];
SetGameFunc(FUNC_RESULTS);
FadeOutAndPlayNewMapMusic(MUS_RG_VICTORY_WILD, 4);
Expand Down
15 changes: 10 additions & 5 deletions src/mini_printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ static s32 _putsAscii(char *s, s32 len, void *buf)
p0 = b->buffer;

/* Copy to buffer */
for (i = 0; i < len; i++) {
if(b->pbuffer == b->buffer + b->buffer_len - 1) {
for (i = 0; i < len; i++)
{
if(b->pbuffer == b->buffer + b->buffer_len - 1)
{
break;
}
*(b->pbuffer ++) = s[i];
Expand All @@ -125,8 +127,10 @@ static s32 _putsEncoded(char *s, s32 len, void *buf)
p0 = b->buffer;

/* Copy to buffer */
for (i = 0; i < len; i++) {
if(b->pbuffer == b->buffer + b->buffer_len - 1) {
for (i = 0; i < len; i++)
{
if(b->pbuffer == b->buffer + b->buffer_len - 1)
{
break;
}
*(b->pbuffer ++) = mini_pchar_decode(s[i]);
Expand Down Expand Up @@ -191,7 +195,8 @@ static s32 mini_pad(char* ptr, s32 len, char pad_char, s32 pad_to, char *buffer)
char * pbuffer = buffer;
if(pad_to == 0)
pad_to = len;
if (len > pad_to) {
if (len > pad_to)
{
len = pad_to;
overflow = TRUE;
}
Expand Down
3 changes: 2 additions & 1 deletion src/slot_machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -3324,7 +3324,8 @@ static void SpriteCB_FlashMatchingLines(struct Sprite *sprite)
if (sprite->sNumFullFlashes)
sprite->sNumFullFlashes--;
}
else if (sprite->sColor >= maxColorChange) {
else if (sprite->sColor >= maxColorChange)
{
// Reached peak darkness, reverse
sprite->sColorIncr = -sprite->sColorIncr;
}
Expand Down

0 comments on commit 1eadbc3

Please sign in to comment.