Forums WoW Modding Support Archives Azerothcore Discord Archives [DiscordArchive] @here If I had this

[DiscordArchive] @here If I had this

[DiscordArchive] @here If I had this

rektbyfaith
Administrator
0
05-13-2019, 10:25 AM
#1
Archived author: Claudiodfc • Posted: 2019-05-13T10:25:25.661000+00:00
Original source

@here If I had this
```
void UpdateAI(uint32 diff) override
{
(...)
Creature* fireSpirit = me->FindNearestCreature(NPC_FIRE_SPIRIT, 1.0f, true);
(...)
```

Every time that `fireSpirit` pointed to a different creature would I lose the last creature causing a leak? Or is it not dynamically allocated?
rektbyfaith
05-13-2019, 10:25 AM #1

Archived author: Claudiodfc • Posted: 2019-05-13T10:25:25.661000+00:00
Original source

@here If I had this
```
void UpdateAI(uint32 diff) override
{
(...)
Creature* fireSpirit = me->FindNearestCreature(NPC_FIRE_SPIRIT, 1.0f, true);
(...)
```

Every time that `fireSpirit` pointed to a different creature would I lose the last creature causing a leak? Or is it not dynamically allocated?

rektbyfaith
Administrator
0
05-13-2019, 10:38 AM
#2
Archived author: Nix • Posted: 2019-05-13T10:38:53.407000+00:00
Original source

I'm pretty sure it points to the original creature pointer, so it should be fine.
rektbyfaith
05-13-2019, 10:38 AM #2

Archived author: Nix • Posted: 2019-05-13T10:38:53.407000+00:00
Original source

I'm pretty sure it points to the original creature pointer, so it should be fine.

rektbyfaith
Administrator
0
05-13-2019, 10:50 AM
#3
Archived author: Claudiodfc • Posted: 2019-05-13T10:50:03.583000+00:00
Original source

Thanks
rektbyfaith
05-13-2019, 10:50 AM #3

Archived author: Claudiodfc • Posted: 2019-05-13T10:50:03.583000+00:00
Original source

Thanks

rektbyfaith
Administrator
0
05-13-2019, 10:50 AM
#4
Archived author: Claudiodfc • Posted: 2019-05-13T10:50:23.299000+00:00
Original source

would you point them to nullptr after used <@171604048733011968>?
rektbyfaith
05-13-2019, 10:50 AM #4

Archived author: Claudiodfc • Posted: 2019-05-13T10:50:23.299000+00:00
Original source

would you point them to nullptr after used <@171604048733011968>?

rektbyfaith
Administrator
0
05-13-2019, 10:56 AM
#5
Archived author: Nix • Posted: 2019-05-13T10:56:06.793000+00:00
Original source

I would probably wrap it like this

```cpp
if (Creature* fireSpirit = me->FindNearestCreature(NPC_FIRE_SPIRIT, 1.0f, true);
{

}
```
rektbyfaith
05-13-2019, 10:56 AM #5

Archived author: Nix • Posted: 2019-05-13T10:56:06.793000+00:00
Original source

I would probably wrap it like this

```cpp
if (Creature* fireSpirit = me->FindNearestCreature(NPC_FIRE_SPIRIT, 1.0f, true);
{

}
```

rektbyfaith
Administrator
0
05-13-2019, 10:56 AM
#6
Archived author: Nix • Posted: 2019-05-13T10:56:42.556000+00:00
Original source

This way the pointer only exists within the local scope, and you won't have to 'care' about it after you leave the scope.
rektbyfaith
05-13-2019, 10:56 AM #6

Archived author: Nix • Posted: 2019-05-13T10:56:42.556000+00:00
Original source

This way the pointer only exists within the local scope, and you won't have to 'care' about it after you leave the scope.

rektbyfaith
Administrator
0
05-13-2019, 11:00 AM
#7
Archived author: Claudiodfc • Posted: 2019-05-13T11:00:57.448000+00:00
Original source

neat, thanks
rektbyfaith
05-13-2019, 11:00 AM #7

Archived author: Claudiodfc • Posted: 2019-05-13T11:00:57.448000+00:00
Original source

neat, thanks

Recently Browsing
 1 Guest(s)
Recently Browsing
 1 Guest(s)