87 lines
1.4 KiB
C
87 lines
1.4 KiB
C
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include "config.h"
|
|
|
|
|
|
void xfree(void* p)
|
|
{
|
|
if(p != NULL)
|
|
{
|
|
free(p);
|
|
}
|
|
}
|
|
|
|
void freeComposeId(char** id)
|
|
{
|
|
if(id == NULL)
|
|
{
|
|
return;
|
|
}
|
|
size_t i = 0;
|
|
while(id[i] != NULL)
|
|
{
|
|
free(id[i]);
|
|
i++;
|
|
}
|
|
free(id);
|
|
}
|
|
|
|
|
|
uint8_t compareComposeId(char** idA, char** idB)
|
|
{
|
|
size_t i = 0;
|
|
while(idA[i] != NULL && idB[i] != NULL)
|
|
{
|
|
if(strcmp(idA[i], idB[i]) != 0)
|
|
{
|
|
return 0;
|
|
}
|
|
i++;
|
|
}
|
|
return idA[i] == NULL && idB[i] == NULL;
|
|
}
|
|
|
|
void freeMemSegConf(conf_mem_seg_t* memSegConf)
|
|
{
|
|
if(memSegConf == NULL)
|
|
{
|
|
return;
|
|
}
|
|
xfree(memSegConf->name);
|
|
}
|
|
void freeMemConf(conf_mem_t* memConf)
|
|
{
|
|
if(memConf == NULL)
|
|
{
|
|
return;
|
|
}
|
|
for(size_t i = 0; i < 0xFF && memConf->memSegConfs[i] != NULL; i++)
|
|
{
|
|
freeMemSegConf(memConf->memSegConfs[i]);
|
|
}
|
|
xfree(memConf->memSegConfs);
|
|
free(memConf);
|
|
}
|
|
void freeConf(conf_dev_t* conf)
|
|
{
|
|
if(conf == NULL)
|
|
{
|
|
return;
|
|
}
|
|
if(conf->clockId != NULL)
|
|
{
|
|
size_t i = 0;
|
|
while(conf->clockId[i] != NULL)
|
|
{
|
|
free(conf->clockId[i]);
|
|
i++;
|
|
}
|
|
free(conf->clockId);
|
|
}
|
|
freeComposeId(conf->id);
|
|
xfree(conf->libPath);
|
|
freeMemConf(conf->memConf);
|
|
free(conf);
|
|
}
|