# getEventCount() works, getEventList() does not

**URL:** <https://qa.fmod.com/t/geteventcount-works-geteventlist-does-not/17894>\
**Category:** FMOD Engine\
**Tags:** cpp\
**Created:** [November 2, 2021, 6:07am UTC](https://qa.fmod.com/t/geteventcount-works-geteventlist-does-not/17894 "2021-11-02T06:07:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cole.peterson](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cole.peterson](https://qa.fmod.com/u/cole.peterson)\
**Post date:** [November 2, 2021, 6:07am UTC](https://qa.fmod.com/t/geteventcount-works-geteventlist-does-not/17894/1 "2021-11-02T06:07:20Z")

</div>

Hi, I’m trying to get a list of events associated with a bank by using getEventList. If I use getEventCount, the returned value is correct but getEventList always returns 0 for both the count and the array. Why could this be happening?

The code:

```auto
FMOD::Studio::Bank* sfxBank;
result = system_->loadBankFile("assets/audio/banks/SFX.bank", FMOD_STUDIO_LOAD_BANK_NORMAL, &sfxBank); // Load bank into FMOD api

int eCount;
FMOD::Studio::EventDescription** eventList = nullptr;
//sfxBank->getEventCount(&eCount);
sfxBank->getEventList(eventList, 512, &eCount);

```

result: eCount = 0 and eventList is still NULL

I have also tried to use getStringInfo() for the same purpose and I get the same behavior.  
Any ideas why this is happening?  
Is there a better way to get a list of all event names?  
Thanks.

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [November 4, 2021, 4:30am UTC](https://qa.fmod.com/t/geteventcount-works-geteventlist-does-not/17894/2 "2021-11-04T04:30:26Z")

</div>

I think the problem is due to undefined behaviour resulting from giving eventList a default value of nullptr- this crashes on my compiler which is trying to protect me from writing to the nullptr address. To get this to work you either need to initialise eventList with a pointer to nullptr that isn’t also nullptr (not recommended, but demonstrates the problem)

```auto
    int c1, c2;
    sfxBank->getEventCount(&c1);
    FMOD::Studio::EventDescription *nothing = nullptr;
    FMOD::Studio::EventDescription **eventList = &nothing;
    sfxBank->getEventList(eventList, 512, &c2);

```

Or you need to change EventDescription to a single pointer and pass its address to `getEventList` (recommneded)

```auto
    int c1, c2;
    sfxBank->getEventCount(&c1);
    FMOD::Studio::EventDescription *eventList = nullptr;
    sfxBank->getEventList(&eventList, 512, &c2);

```

If that doesn’t solve the problem, can you please tell me what your version of FMOD is so I can try to reproduce the issue?

---

<div class="post-metadata">

**Author:** ![cole.peterson](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cole.peterson](https://qa.fmod.com/u/cole.peterson)\
**Post date:** [November 5, 2021, 11:47pm UTC](https://qa.fmod.com/t/geteventcount-works-geteventlist-does-not/17894/3 "2021-11-05T23:47:59Z")

</div>

Im on 2.01. It seems that your answer solved part of it (single pointer, use the address of). If I insert a breakpoint right after the call, I can see the correct value and an address for eventList, however, when the function returns I get an exception “the stack around variable eventList was corrupted.”

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [November 7, 2021, 10:39pm UTC](https://qa.fmod.com/t/geteventcount-works-geteventlist-does-not/17894/4 "2021-11-07T22:39:37Z")

</div>

Double checking the [docs](https://fmod.com/resources/documentation-api?version=2.01&page=studio-api-bank.html#studio_bank_geteventlist) I see that eventList is supposed to be an array. Can you please see if this works for you?

```auto
int count;
sfxBank->getEventCount(&count);
FMOD::Studio::EventDescription* eventList[512];
sfxBank->getEventList(&*eventList, 512, &count);

for (int i = 0; i < count; ++i)
{
    char path[512];
    int *retrieved = nullptr;
    eventList[i]->getPath(path, 512, retrieved);
    Common_Draw(path);
}

```

Can you also please tell me what minor version you are on? e.g 2.01.09, 2.01.12?

---

<div class="post-metadata">

**Author:** ![cole.peterson](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cole.peterson](https://qa.fmod.com/u/cole.peterson)\
**Post date:** [November 8, 2021, 11:59pm UTC](https://qa.fmod.com/t/geteventcount-works-geteventlist-does-not/17894/5 "2021-11-08T23:59:16Z")

</div>

```auto
FMOD::Studio::EventDescription* eventList[512];
sfxBank->getEventList(&*eventList, 512, &count);

```

That did the trick, thanks. I guess that makes sense but a small example in the docs would be nice for that kind of thing.  
Thanks again.
