Fixed resizing of PubSub
This commit is contained in:
parent
b48a737299
commit
bcfa434da2
@ -84,7 +84,7 @@ void PubSub_AddEventTypes(wPubSub* pubSub, wEventType* events, int count)
|
||||
wEventType *new_event;
|
||||
|
||||
new_size = pubSub->size * 2;
|
||||
new_event = (wEventType*) realloc(pubSub->events, new_size);
|
||||
new_event = (wEventType*) realloc(pubSub->events, new_size * sizeof(wEventType));
|
||||
if (!new_event)
|
||||
return;
|
||||
pubSub->size = new_size;
|
||||
@ -151,7 +151,7 @@ int PubSub_Unsubscribe(wPubSub* pubSub, const char* EventName, pEventHandler Eve
|
||||
event->EventHandlers[index] = NULL;
|
||||
event->EventHandlerCount--;
|
||||
MoveMemory(&event->EventHandlers[index], &event->EventHandlers[index + 1],
|
||||
(MAX_EVENT_HANDLERS - index - 1) * sizeof(pEventHandler));
|
||||
(MAX_EVENT_HANDLERS - index - 1) * sizeof(pEventHandler));
|
||||
status = 1;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user