From f49aa0e0ef174b7e6a2e225ae3bebfa46f7a7c4a Mon Sep 17 00:00:00 2001 From: Joshua Kwan Date: Sat, 3 Jan 2004 02:10:35 +0000 Subject: [PATCH] use an ARRAY_SIZE macro if available, if not, #define it git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@49 db0b04b0-f4d1-0310-9a6d-de3e77497b0e --- dgamelaunch.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/dgamelaunch.c b/dgamelaunch.c index 7562f27..f27e0d3 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -58,6 +58,11 @@ #ifdef __linux__ # include +# include +#endif + +#ifndef ARRAY_SIZE +# define ARRAY_SIZE(x) sizeof(x) / sizeof(x[0]) #endif #include @@ -207,7 +212,7 @@ loadbanner (struct dg_banner *ban) { strncat (bufnew, VERSION, 80 - i); b += 8; /* skip the whole $VERSION string */ - i += sizeof (VERSION) / sizeof (VERSION[0]); + i += ARRAY_SIZE(VERSION); } if (strlen (b) == 0) @@ -484,9 +489,7 @@ domailuser (char *username) assert (loggedin); - len = - (sizeof (LOC_SPOOLDIR) / sizeof (LOC_SPOOLDIR[0])) + strlen (username) + - 1; + len = ARRAY_SIZE(LOC_SPOOLDIR) + strlen (username) + 1; spool_fn = malloc (len + 1); time (&now); snprintf (spool_fn, len, "%s/%s", LOC_SPOOLDIR, username); @@ -1153,9 +1156,7 @@ main (void) /* environment */ snprintf (atrcfilename, 81, "@%s", rcfilename); - len = - (sizeof (LOC_SPOOLDIR) / sizeof (LOC_SPOOLDIR[0])) + - strlen (me->username) + 1; + len = ARRAY_SIZE(LOC_SPOOLDIR) + strlen (me->username) + 1; spool = malloc (len + 1); snprintf (spool, len, "%s/%s", LOC_SPOOLDIR, me->username);