* Try to allocate an structure 'lwp_shm_struct' from the freed list or the * static array. */
| 81 | * static array. |
| 82 | */ |
| 83 | static int _shm_id_alloc(void) |
| 84 | { |
| 85 | int id = -1; |
| 86 | |
| 87 | if (shm_free_list != -1) /* first try the freed list */ |
| 88 | { |
| 89 | id = shm_free_list; |
| 90 | shm_free_list = (int)_shm_ary[shm_free_list].addr; /* single-direction */ |
| 91 | } |
| 92 | else if (shm_id_used < RT_LWP_SHM_MAX_NR) /* then try the array */ |
| 93 | { |
| 94 | id = shm_id_used; |
| 95 | shm_id_used++; |
| 96 | } |
| 97 | return id; |
| 98 | } |
| 99 | |
| 100 | /* Release the item in the static array to the freed list. */ |
| 101 | static void shm_id_free(int id) |