# Clarification for "array of memory allocated by the user"

**URL:** <https://qa.fmod.com/t/clarification-for-array-of-memory-allocated-by-the-user/11575>\
**Category:** FMOD Studio\
**Created:** [July 25, 2014, 4:53pm UTC](https://qa.fmod.com/t/clarification-for-array-of-memory-allocated-by-the-user/11575 "2014-07-25T16:53:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HE-Dev](https://avatars.discourse-cdn.com/v4/letter/h/8797f3/32.png) [@HE-Dev](https://qa.fmod.com/u/HE-Dev)\
**Post date:** [July 25, 2014, 4:53pm UTC](https://qa.fmod.com/t/clarification-for-array-of-memory-allocated-by-the-user/11575/1 "2014-07-25T16:53:09Z")

</div>

In updating to a new version, we have a question. For functions that require an “array of memory allocated by the user”, it’s unclear to us what that actually means. Does that mean 1) an array of classes?, or 2) an array of class pointers?

This is one such function:

```
FMOD_RESULT Studio::Bank::getEventList(
  Studio::EventDescription **array,
  int capacity,
  int *count
);

```

We’ve tried both ways, and examined memory, and get varying event-not-found error messages in trying to use the returned data.

This is complicated by the fact that `Studio::EventDescription` has a private constructor. Which lead us to believe that it was intended as an array of `Studio::EventDescription *`, however, that doesn’t seem to work either. Any advice?

[RESOLVED] The root cause of the problem ended up being that the master bank and master bank string files were not loaded. There’s nothing explicit in the docs that says they’re required except a single line partway down the page on upgrading. And, it contradicts the one or two places that say that banks are monolithic (as opposed to the old fev/fsb relationship) and you don’t need to load anything else.

---

<div class="post-metadata">

**Author:** ![buzzrick](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/buzzrick/32/473_2.png) [@buzzrick](https://qa.fmod.com/u/buzzrick)\
**Post date:** [July 27, 2014, 9:22pm UTC](https://qa.fmod.com/t/clarification-for-array-of-memory-allocated-by-the-user/11575/2 "2014-07-27T21:22:43Z")

</div>

I believe that the array of pointers needs to be allocated, something like this:

```
int maxLen = 255;
char buffer[maxLen + 1];

Studio::Bank* bank = [[existing bank]];
// iterate the events in this Bank
int eventCount = 0;
if (FMOD_ErrorCheck(bank->getEventCount(&eventCount)))
{
    Studio::EventDescription**array = (Studio::EventDescription**)malloc(eventCount * sizeof(void*));
    
    if (FMOD_ErrorCheck(bank->getEventList(array, eventCount, &eventCount)))
    {
        for (int i = 0; i < eventCount; i++) {
            if (FMOD_ErrorCheck(array[i]->getPath(buffer, maxLen, 0)))
            {
                CCLOG("Found event: %s", buffer);
            }
            else
            {
                CCLOG("Unable to determine event details");
            }
        }
    }
    free(array);
}

```

Pretty much all of the FMOD methods that return lists work the same way.

It would be good if they could include a code snippet similar to the above in the documentation because I, too, spent quite some time figuring it out.

PS: You are correct when you say that the EventDescription constructor is private, so we can’t instantiate them ourselves manually

Hope that helps

---

<div class="post-metadata">

**Author:** ![HE-Dev](https://avatars.discourse-cdn.com/v4/letter/h/8797f3/32.png) [@HE-Dev](https://qa.fmod.com/u/HE-Dev)\
**Post date:** [July 27, 2014, 11:17pm UTC](https://qa.fmod.com/t/clarification-for-array-of-memory-allocated-by-the-user/11575/3 "2014-07-27T23:17:36Z")

</div>

The root cause of the problem ended up being that the master bank and master bank string files were not loaded. There’s nothing explicit in the docs that says they’re required except a single line partway down the page on upgrading. And, it contradicts the one or two places that say that banks are monolithic (as opposed to the old fev/fsb relationship) and you don’t need to load anything else.
