+/*
+ * Get a set of DateFormat symbols of a given type.
+ *
+ * lowestIndex is the index of the first symbol to fetch.
+ * (e.g. it will be one to fetch day names, since Sunday is
+ * day 1 *not* day 0.)
+ *
+ * firstIndex is the index of the symbol to place first in
+ * the output array. This is used when fetching day names
+ * in locales where the week doesn't start on Sunday.
+ */
+static void get_symbols(const UDateFormat *fmt,
+ UDateFormatSymbolType type,
+ UChar *array[],
+ int32_t arrayLength,
+ int32_t lowestIndex,
+ int32_t firstIndex,
+ UErrorCode *status)
+{
+ int32_t count, i;
+
+ if (U_FAILURE(*status)) {
+ return;
+ }
+
+ count = udat_countSymbols(fmt, type);
+
+ if(count != arrayLength + lowestIndex) {
+ return;
+ }
+
+ for(i = 0; i < arrayLength; i++) {
+ int32_t idx = (i + firstIndex) % arrayLength;
+ int32_t size = 1 + udat_getSymbols(fmt, type, idx + lowestIndex, NULL, 0, status);
+
+ array[idx] = (UChar *) malloc(sizeof(UChar) * size);
+
+ *status = U_ZERO_ERROR;
+ udat_getSymbols(fmt, type, idx + lowestIndex, array[idx], size, status);
+ }
+}
+
+/* Free the symbols allocated by get_symbols(). */
+static void free_symbols(UChar *array[],
+ int32_t arrayLength)
+{
+ int32_t i;
+
+ for(i = 0; i < arrayLength; i++) {
+ free(array[i]);
+ }
+}