12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #include "freeTrajInfo.h"
- void freeTrajInfo(cmscp_trajInfo** traj, cmscp_setup* setup, int level)
- {
- // 释放cmscp_trajInfo结构体空间
- // level 为 0 的时候只释放2级下的内存
- // level 大于 0 的时候全部释放
- int iphase;
- if (traj)
- {
- if (level >= 0)
- {
- for (iphase = 0; iphase < setup->numPhase; iphase++)
- {
- freeTrajInfoPhase(traj, setup, iphase);
- }
- }
- if (level > 0)
- {
- free(traj);
- }
- }
- }
- void freeTrajInfoPhase(cmscp_trajInfo** traj, cmscp_setup* setup, int iphase)
- {
- if (traj[iphase])
- {
- if (traj[iphase]->control)
- {
- if (traj[iphase]->control->v)
- {
- free(traj[iphase]->control->v);
- }
- free(traj[iphase]->control);
- }
- if (traj[iphase]->state)
- {
- if (traj[iphase]->state->v)
- {
- free(traj[iphase]->state->v);
- }
- free(traj[iphase]->state);
- }
- if (traj[iphase]->parameter)
- {
- free(traj[iphase]->parameter);
- }
- free(traj[iphase]);
- }
- }
|