mirror of
https://github.com/Derisis13/Shutter.git
synced 2025-12-06 19:32:48 +01:00
Version 1.5.1
Added dynamic memory management for shutters (functions in shutter.c). Code is now much easier to tailor to specific needs and works better in the limited RAM of routers. Memory leaks were not found by Valgrind Memcheck.
This commit is contained in:
35
shutter.c
Normal file
35
shutter.c
Normal file
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// Created by lacko on 18/09/2021.
|
||||
//
|
||||
#include "shutter.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
shutter *create_shutter (byte ch, byte rolltime_down)
|
||||
{
|
||||
shutter *new_shutter = calloc (1, sizeof (shutter));
|
||||
new_shutter->ch = ch;
|
||||
new_shutter->rolltime_down = rolltime_down;
|
||||
return new_shutter;
|
||||
}
|
||||
|
||||
void append_shutter (shutter **head, shutter *new_shutter)
|
||||
{
|
||||
if (*head == NULL)
|
||||
{
|
||||
*head = new_shutter;
|
||||
return;
|
||||
}
|
||||
shutter *tmp = *head;
|
||||
while (tmp->next != NULL)
|
||||
tmp = tmp->next;
|
||||
tmp->next = new_shutter;
|
||||
}
|
||||
|
||||
void free_shutters (shutter *head)
|
||||
{
|
||||
for (shutter *tmp = head; head != NULL; tmp = head)
|
||||
{
|
||||
head = head->next;
|
||||
free (tmp);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user