Osiris_FreeMemoryForScript Purpose: Frees all memory allocated for a given script
| 2960 | // Purpose: |
| 2961 | // Frees all memory allocated for a given script |
| 2962 | void Osiris_FreeMemoryForScript(tOSIRISSCRIPTID *sid) { |
| 2963 | if (!Osiris_mem_root) |
| 2964 | return; |
| 2965 | bool done = false; |
| 2966 | tOSIRISMEMNODE *curr, *next, *prev; |
| 2967 | curr = Osiris_mem_root; |
| 2968 | prev = NULL; |
| 2969 | |
| 2970 | while (!done) { |
| 2971 | if (!curr) { |
| 2972 | done = true; |
| 2973 | } else { |
| 2974 | next = curr->next; |
| 2975 | |
| 2976 | if (compareid(sid, &curr->chunk_id.my_id)) { |
| 2977 | // this has to go |
| 2978 | if (curr == Osiris_mem_root) { |
| 2979 | // removing root |
| 2980 | Osiris_mem_root = curr->next; |
| 2981 | |
| 2982 | if (curr->memory) |
| 2983 | mem_free(curr->memory); |
| 2984 | mem_free(curr); |
| 2985 | } else { |
| 2986 | // remove from list and pull back |
| 2987 | prev->next = curr->next; |
| 2988 | |
| 2989 | if (curr->memory) |
| 2990 | mem_free(curr->memory); |
| 2991 | mem_free(curr); |
| 2992 | } |
| 2993 | } else { |
| 2994 | prev = curr; |
| 2995 | } |
| 2996 | |
| 2997 | curr = next; |
| 2998 | } |
| 2999 | } |
| 3000 | } |
| 3001 | |
| 3002 | // Osiris_SaveMemoryChunks |
| 3003 | // Purpose: |
no test coverage detected