malloc Überprüfung

This commit is contained in:
Timo Hertel 2025-12-15 14:36:30 +01:00
parent 56430b513e
commit f407f0f837

View File

@ -15,6 +15,10 @@ StackNode *push(StackNode *stack, void *data)
{
StackNode *newNode;
newNode = (StackNode *)malloc(sizeof(StackNode));
if (!newNode)
printf("Speicherfehler: nicht genug Speicher");
return stack;
newNode->data = data;
// ,-→ bedeutet Liste war leer - das neue Element hat keinen Nachfolger (next = NULL)