Skip to content

Commit

Permalink
Use ARRAY_SIZE macro to make alloc size array dynamically sized.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpd002 committed Apr 20, 2016
1 parent 63e3edf commit bcd6015
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 2 additions & 0 deletions common/common-iop.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
void schedf(const char *format, ...);
void flushschedf();

#define ARRAY_SIZE(a) (sizeof((a)) / (sizeof((a)[0])))

#endif
8 changes: 3 additions & 5 deletions tests/kernel/iop/vpool/pallocate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
#include <thpool.h>
#include "vpl-common.h"

#define MAX_ALLOC_SIZES 24

static const s32 g_allocSizes[MAX_ALLOC_SIZES] = {
static const s32 g_allocSizes[] = {
0x80, 0x81, 0x82, 0x83,
0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8A, 0x8B,
Expand Down Expand Up @@ -34,7 +32,7 @@ void testSingleAllocs() {
s32 vplId = CreateVpl(&vplParam);

s32 i = 0;
for(i = 0; i < MAX_ALLOC_SIZES; i++) {
for(i = 0; i < ARRAY_SIZE(g_allocSizes); i++) {
s32 allocSize = g_allocSizes[i];
printf(" allocate %d bytes:\n", allocSize);
printf(" "); doAllocate(vplId, allocSize);
Expand All @@ -57,7 +55,7 @@ void testMultiAllocs() {
pAllocateVpl(vplId, 0x100);

s32 i = 0;
for(i = 0; i < MAX_ALLOC_SIZES; i++) {
for(i = 0; i < ARRAY_SIZE(g_allocSizes); i++) {
s32 allocSize = g_allocSizes[i];
printf(" allocate %d bytes:\n", allocSize);
printf(" "); doAllocate(vplId, allocSize);
Expand Down

0 comments on commit bcd6015

Please sign in to comment.