How to return a list of numbers from a function?

I am trying to figure out the easiest/best/standard/accepted/foolproof way to return a list of numbers (an array?) from a function, including how many numbers are in the list.

Currently, I am doing it by passing in an array by reference, and returning the number of elements I put into that array. I used the method in this article http://forum.arduino.cc/index.php/topic,42934.0.html as my guide. It's working, but it seems to me there must be a better way, particularly since it seems I have to predefine the array and it's size before calling my function. (Therefore, I must make the array at least as big as my expected result set, and when populating the results make sure not to go past the end.)

My function is:

int isHoliday(dateTime dt, int *holidayList)

Where:
isHoliday is the name of the function (duh!)
dateTime dt is a date-time structure containing month, day of the month, weekday, year, etc.
holidayList is my predefined array of integers to hold the results
And the return value is how many holidays occur on that day and how many elements were set in the array, possibly zero.
I should also note that the holidays are enumated with constant int values assigned to them, there are quite a few of them, (See: http://www.holidayinsights.com) and there is definite possibility that a certain date may match several of them, or it may not match any and return zero and an empty list.
This is for a digital clock project that also reminds me of birthdays, anniversaries, standard, and weird/fun holidays on the LCD display.
My regular day job is programming in C#, and the similarities-yet-differences between it and straight C/C++ drive me nuts when I try to program the Arduino.

Make a global array and just have the function do whatever it does to the array.
Then other functions, or code in loop, can access the array also.

I make all my variables global, lets any code access anything.

It's working, but it seems to me there must be a better way, particularly since it seems I have to predefine the array and it's size before calling my function.

The alternative is to use dynamic memory allocation - not a great alternative on a system with so little memory.

The approach you used seems like a reasonable one to me.

Using dynamic memory as PaulS suggested would be one way to avoid the fixed allocation, but I don’t like that approach any more than he did.

One alternative approach is to do the allocation in two steps - the first step returns the number of entries that need to be returned, and the second one returns the entries. This complicates the implementation slightly but means you can allocate the array dynamically on the stack:

int count = holidayCount(dt);
if(count > 0)
{
    int holidays[count];
    getHolidays(dt, holidays);
    for(int i = 0; i < count; i++)
    {
        // do something with each holiday
    }
}

I doubt that the data you’re dealing with is going to be large enough to warrant this complexity, but this is a way to deal with arbitrarily large structures without relying on heap memory, and all the issues that introduces.

OK, thanks for your suggestions guys. I guess I stick with what I've already got, since it works.

Making everything global is not a very good solution (although I've been known to do that myself). Keeping the scope of variables and things as narrow as possible is a much better way to do things. More re-usability of code and less problems. Also, I forsee having to work with more than one list.