mem_mngt.c 19.2 KB
Newer Older
1 2 3 4 5
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
6
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */

22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
/***************************************************************************
                          mem_mngt.c  -  description
                             -------------------
  AUTHOR  : Lionel GAUTHIER
  COMPANY : EURECOM
  EMAIL   : Lionel.Gauthier@eurecom.fr


 ***************************************************************************/
#define MEM_MNGT_C
#include "rtos_header.h"
#include "platform.h"
#include "protocol_vars_extern.h"
#include "print.h"

#include "mem_block.h"
#include "mem_pool.h"
#include "lists_proto_extern.h"
#include "umts_sched.h"
//-----------------------------------------------------------------------------
#define DEBUG_MEM_MNGT_FREE
#define DEBUG_MEM_MNGT_ALLOC_SIZE
#define DEBUG_MEM_MNGT_ALLOC
#ifdef DEBUG_MEM_MNGT_ADDR
#    define   PRINT_MEM_MNGT_ADDR msg
#else
#    define   PRINT_MEM_MNGT_ADDR
49
//
50 51
#endif
//-----------------------------------------------------------------------------
52
uint32_t             counters[11] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
53 54 55 56 57 58 59
//-----------------------------------------------------------------------------
/*
 * initialize all ures
 */
void           *
pool_buffer_init (void *arg)
{
60
  //-----------------------------------------------------------------------------
61

62
  uint32_t             index, mb_index, pool_index;
63 64
  mem_pool       *memory = (mem_pool *) arg;
  int             pool_sizes[11] = { MEM_MNGT_MB0_NB_BLOCKS, MEM_MNGT_MB1_NB_BLOCKS,
65 66 67 68 69 70
                                     MEM_MNGT_MB2_NB_BLOCKS, MEM_MNGT_MB3_NB_BLOCKS,
                                     MEM_MNGT_MB4_NB_BLOCKS, MEM_MNGT_MB5_NB_BLOCKS,
                                     MEM_MNGT_MB6_NB_BLOCKS, MEM_MNGT_MB7_NB_BLOCKS,
                                     MEM_MNGT_MB8_NB_BLOCKS, MEM_MNGT_MB9_NB_BLOCKS,
                                     MEM_MNGT_MBCOPY_NB_BLOCKS
                                   };
71 72 73

  memset (memory, 0, sizeof (mem_pool));
  mb_index = 0;
74

75 76 77
  // LG_TEST
  for (pool_index = 0; pool_index <= MEM_MNGT_POOL_ID_COPY; pool_index++) {
    init_list (&memory->mem_lists[pool_index], "POOL");
78

79 80 81 82
    for (index = 0; index < pool_sizes[pool_index]; index++) {
      //memory->mem_blocks[mb_index + index].previous = NULL; -> done in memset 0
      //memory->mem_blocks[mb_index + index].next     = NULL; -> done in memset 0
      switch (pool_index) {
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
      case 0:
        memory->mem_blocks[mb_index + index].data = &(memory->mem_pool0[index][0]);
        break;

      case 1:
        memory->mem_blocks[mb_index + index].data = &(memory->mem_pool1[index][0]);
        break;

      case 2:
        memory->mem_blocks[mb_index + index].data = &(memory->mem_pool2[index][0]);
        break;

      case 3:
        memory->mem_blocks[mb_index + index].data = &(memory->mem_pool3[index][0]);
        break;

      case 4:
        memory->mem_blocks[mb_index + index].data = &(memory->mem_pool4[index][0]);
        break;

      case 5:
        memory->mem_blocks[mb_index + index].data = &(memory->mem_pool5[index][0]);
        break;

      case 6:
        memory->mem_blocks[mb_index + index].data = &(memory->mem_pool6[index][0]);
        break;

      case 7:
        memory->mem_blocks[mb_index + index].data = &(memory->mem_pool7[index][0]);
        break;

      case 8:
        memory->mem_blocks[mb_index + index].data = &(memory->mem_pool8[index][0]);
        break;

      case 9:
        memory->mem_blocks[mb_index + index].data = &(memory->mem_pool9[index][0]);
        break;

      default:
        ;
        memory->mem_blocks[mb_index + index].data = NULL;   // pool copy
126 127

      }
128

129 130 131
      memory->mem_blocks[mb_index + index].pool_id = pool_index;
      add_tail (&memory->mem_blocks[mb_index + index], &memory->mem_lists[pool_index]);
    }
132

133 134
    mb_index += pool_sizes[pool_index];
  }
135

136 137 138 139 140 141 142
  return 0;
}

//-----------------------------------------------------------------------------
void           *
pool_buffer_clean (void *arg)
{
143
  //-----------------------------------------------------------------------------
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
#ifndef NO_THREAD_SAFE
  mem_pool       *memory = (mem_pool *) arg;
  pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID0].mutex);
  pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID1].mutex);
  pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID2].mutex);
  pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID3].mutex);
  pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID4].mutex);
  pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID5].mutex);
  pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID6].mutex);
  pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID7].mutex);
  pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID8].mutex);
  pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID9].mutex);
  pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID_COPY].mutex);
#endif
  return 0;
}
//-----------------------------------------------------------------------------
void
162
free_mem_block (mem_block_t * leP, __func__)
163
{
164
  //-----------------------------------------------------------------------------
165 166 167 168 169

  if (!(leP)) {
    msg ("[MEM_MNGT][FREE] WARNING FREE NULL MEM_BLOCK\n");
    return;
  }
170

171
#ifdef DEBUG_MEM_MNGT_FREE
172
  msg ("[MEM_MNGT][FREE] free_mem_block() %p pool: %d\n", leP, leP->pool_id, __func__);
173 174
#endif
#ifdef DEBUG_MEM_MNGT_ALLOC
175
  check_free_mem_block (leP, __func__);
176 177 178 179 180 181 182 183 184
#endif

  if (leP->pool_id <= MEM_MNGT_POOL_ID_COPY) {
    add_tail (leP, &mem->mem_lists[leP->pool_id]);
#ifdef DEBUG_MEM_MNGT_ALLOC
    counters[leP->pool_id] -= 1;
#endif
    leP = NULL;                 // this prevent from freeing the block twice
  } else {
185
    msg ("[MEM_MNGT][FREE] ERROR free_mem_block() unknown pool_id : %d\n", leP->pool_id, __func__);
186 187 188 189 190 191
  }
}


//-----------------------------------------------------------------------------
mem_block_t      *
192
get_free_mem_block (uint16_t sizeP, __func__)
193
{
194
  //-----------------------------------------------------------------------------
195 196 197 198 199 200 201 202 203
  mem_block_t      *le = NULL;
  int             pool_selected;
  int             size;

  if (sizeP > MEM_MNGT_MB9_BLOCK_SIZE) {
    msg ("[MEM_MNGT][ERROR][FATAL] size requested  %d out of bounds %d\n",sizeP,MEM_MNGT_MB9_BLOCK_SIZE);
    wcdma_handle_error (WCDMA_ERROR_OUT_OF_MEM_BLOCK);
    return NULL;
  }
204

205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
  size = sizeP >> 6;
  pool_selected = 0;

  while ((size)) {
    pool_selected += 1;
    size = size >> 1;
  }

  // pool is selected according to the size requested, now get a block
  // if no block is available pick one in an other pool
  do {
    if ((le = remove_head (&mem->mem_lists[pool_selected]))) {
#ifdef DEBUG_MEM_MNGT_ALLOC
      counters[pool_selected] += 1;
#endif
#ifdef DEBUG_MEM_MNGT_ALLOC_SIZE
      msg ("[MEM_MNGT][INFO] ALLOC MEM_BLOCK SIZE %d bytes pool %d\n", sizeP, pool_selected);
#endif
      return le;
    }
225

226 227 228 229 230 231
#ifdef DEBUG_MEM_MNGT_ALLOC
    msg ("[MEM_MNGT][ERROR][MINOR] memory pool %d is empty trying next pool alloc count = %d\n", pool_selected, counters[pool_selected]);
    display_mem_load ();
    check_mem_area (mem);
#endif
  } while (pool_selected++ < 9);
232

233 234 235 236 237 238 239 240 241
  msg ("[MEM_MNGT][ERROR][FATAL] size %d requested out of bounds or memory pools empty\n", sizeP);
  wcdma_handle_error (WCDMA_ERROR_OUT_OF_MEM_BLOCK);
  return NULL;
};

//-----------------------------------------------------------------------------
mem_block_t      *
get_free_copy_mem_block (void)
{
242
  //-----------------------------------------------------------------------------
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
  mem_block_t      *le;

  if ((le = remove_head (&mem->mem_lists[MEM_MNGT_POOL_ID_COPY]))) {
    return le;
  } else {
    msg ("[MEM_MNGT][ERROR] POOL COPY IS EMPTY\n");
    display_mem_load ();
#ifdef DEBUG_MEM_MNGT_ALLOC
    check_mem_area (mem);
    break_point ();
#endif
    wcdma_handle_error (WCDMA_ERROR_OUT_OF_MEM_BLOCK);

    return NULL;
  }
}

//-----------------------------------------------------------------------------
mem_block_t      *
copy_mem_block (mem_block_t * leP, mem_block_t * destP)
{
264
  //-----------------------------------------------------------------------------
265 266 267 268 269 270

  if ((destP != NULL) && (leP != NULL) && (destP->pool_id == MEM_MNGT_POOL_ID_COPY)) {
    destP->data = leP->data;
  } else {
    msg ("[MEM_MNGT][COPY] copy_mem_block() pool dest src or dest is NULL\n");
  }
271

272 273 274 275 276 277 278
  return destP;
}

//-----------------------------------------------------------------------------
void
display_mem_load (void)
{
279
  //-----------------------------------------------------------------------------
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308

  msg ("POOL 0 (%d elements of %d Bytes): \n", MEM_MNGT_MB0_NB_BLOCKS, MEM_MNGT_MB0_BLOCK_SIZE);
  display_list (&mem->mem_lists[MEM_MNGT_POOL_ID0]);
  msg ("POOL 1 (%d elements of %d Bytes): \n", MEM_MNGT_MB1_NB_BLOCKS, MEM_MNGT_MB1_BLOCK_SIZE);
  display_list (&mem->mem_lists[MEM_MNGT_POOL_ID1]);
  msg ("POOL 2 (%d elements of %d Bytes): \n", MEM_MNGT_MB2_NB_BLOCKS, MEM_MNGT_MB2_BLOCK_SIZE);
  display_list (&mem->mem_lists[MEM_MNGT_POOL_ID2]);
  msg ("POOL 3 (%d elements of %d Bytes): \n", MEM_MNGT_MB3_NB_BLOCKS, MEM_MNGT_MB3_BLOCK_SIZE);
  display_list (&mem->mem_lists[MEM_MNGT_POOL_ID3]);
  msg ("POOL 4 (%d elements of %d Bytes): \n", MEM_MNGT_MB4_NB_BLOCKS, MEM_MNGT_MB4_BLOCK_SIZE);
  display_list (&mem->mem_lists[MEM_MNGT_POOL_ID4]);
  msg ("POOL 5 (%d elements of %d Bytes): \n", MEM_MNGT_MB5_NB_BLOCKS, MEM_MNGT_MB5_BLOCK_SIZE);
  display_list (&mem->mem_lists[MEM_MNGT_POOL_ID5]);
  msg ("POOL 6 (%d elements of %d Bytes): \n", MEM_MNGT_MB6_NB_BLOCKS, MEM_MNGT_MB6_BLOCK_SIZE);
  display_list (&mem->mem_lists[MEM_MNGT_POOL_ID6]);
  msg ("POOL 7 (%d elements of %d Bytes): \n", MEM_MNGT_MB7_NB_BLOCKS, MEM_MNGT_MB7_BLOCK_SIZE);
  display_list (&mem->mem_lists[MEM_MNGT_POOL_ID7]);
  msg ("POOL 8 (%d elements of %d Bytes): \n", MEM_MNGT_MB8_NB_BLOCKS, MEM_MNGT_MB8_BLOCK_SIZE);
  display_list (&mem->mem_lists[MEM_MNGT_POOL_ID8]);
  msg ("POOL 9 (%d elements of %d Bytes): \n", MEM_MNGT_MB9_NB_BLOCKS, MEM_MNGT_MB9_BLOCK_SIZE);
  display_list (&mem->mem_lists[MEM_MNGT_POOL_ID9]);
  msg ("POOL C (%d elements): \n", MEM_MNGT_MBCOPY_NB_BLOCKS);
  display_list (&mem->mem_lists[MEM_MNGT_POOL_ID_COPY]);
}

//-----------------------------------------------------------------------------
void
check_mem_area (void *arg)
{
309
  //-----------------------------------------------------------------------------
310 311 312 313 314 315 316 317 318
  int             index, mb_index;
  mem_pool       *memory = (mem_pool *) arg;

  for (index = 0; index < MEM_MNGT_MB0_NB_BLOCKS; index++) {
    if ((memory->mem_blocks[index].data != &(memory->mem_pool0[index][0])) && (memory->mem_blocks[index].pool_id != MEM_MNGT_POOL_ID0)) {
      msg ("[MEM] ERROR POOL0 block index %d\n", index);
      break_point ();
    }
  }
319

320
  mb_index = MEM_MNGT_MB0_NB_BLOCKS;
321

322 323 324 325 326 327
  for (index = 0; index < MEM_MNGT_MB1_NB_BLOCKS; index++) {
    if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool1[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID1)) {
      msg ("[MEM] ERROR POOL1 block index %d\n", index);
      break_point ();
    }
  }
328

329
  mb_index += MEM_MNGT_MB1_NB_BLOCKS;
330

331 332 333 334 335 336
  for (index = 0; index < MEM_MNGT_MB2_NB_BLOCKS; index++) {
    if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool2[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID2)) {
      msg ("[MEM] ERROR POOL2 block index %d\n", index);
      break_point ();
    }
  }
337

338
  mb_index += MEM_MNGT_MB2_NB_BLOCKS;
339

340 341 342 343 344 345
  for (index = 0; index < MEM_MNGT_MB3_NB_BLOCKS; index++) {
    if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool3[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID3)) {
      msg ("[MEM] ERROR POOL3 block index %d\n", index);
      break_point ();
    }
  }
346

347
  mb_index += MEM_MNGT_MB3_NB_BLOCKS;
348

349 350 351 352 353 354
  for (index = 0; index < MEM_MNGT_MB4_NB_BLOCKS; index++) {
    if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool4[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID4)) {
      msg ("[MEM] ERROR POOL4 block index %d\n", index);
      break_point ();
    }
  }
355

356
  mb_index += MEM_MNGT_MB4_NB_BLOCKS;
357

358 359 360 361 362 363
  for (index = 0; index < MEM_MNGT_MB5_NB_BLOCKS; index++) {
    if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool5[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID5)) {
      msg ("[MEM] ERROR POOL5 block index %d\n", index);
      break_point ();
    }
  }
364

365
  mb_index += MEM_MNGT_MB5_NB_BLOCKS;
366

367 368 369 370 371 372
  for (index = 0; index < MEM_MNGT_MB6_NB_BLOCKS; index++) {
    if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool6[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID6)) {
      msg ("[MEM] ERROR POOL6 block index %d\n", index);
      break_point ();
    }
  }
373

374
  mb_index += MEM_MNGT_MB6_NB_BLOCKS;
375

376 377 378 379 380 381
  for (index = 0; index < MEM_MNGT_MB7_NB_BLOCKS; index++) {
    if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool7[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID7)) {
      msg ("[MEM] ERROR POOL7 block index %d\n", index);
      break_point ();
    }
  }
382

383
  mb_index += MEM_MNGT_MB7_NB_BLOCKS;
384

385 386 387 388 389 390
  for (index = 0; index < MEM_MNGT_MB8_NB_BLOCKS; index++) {
    if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool8[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID8)) {
      msg ("[MEM] ERROR POOL8 block index %d\n", index);
      break_point ();
    }
  }
391

392
  mb_index += MEM_MNGT_MB8_NB_BLOCKS;
393

394 395 396 397 398 399
  for (index = 0; index < MEM_MNGT_MB9_NB_BLOCKS; index++) {
    if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool9[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID9)) {
      msg ("[MEM] ERROR POOL9 block index %d\n", index);
      break_point ();
    }
  }
400

401
  mb_index += MEM_MNGT_MB9_NB_BLOCKS;
402

403 404 405 406 407 408 409 410 411 412
  for (index = mb_index; index < MEM_MNGT_NB_ELEMENTS; index++) {
    if ((memory->mem_blocks[index].data != NULL) && (memory->mem_blocks[index].pool_id != MEM_MNGT_POOL_ID_COPY)) {
      msg ("[MEM] ERROR POOL COPY block index %d\n", index);
      break_point ();
    }
  }
}

//-----------------------------------------------------------------------------
void
413
check_free_mem_block (mem_block_t * leP, __func__)
414
{
415
  //-----------------------------------------------------------------------------
416
  int             block_index;
417

418
  if ((leP >= &mem->mem_blocks[0]) && (leP <= &mem->mem_blocks[MEM_MNGT_NB_ELEMENTS])) {
419
    block_index = ((uint32_t) leP - (uint32_t) (&mem->mem_blocks[0])) / sizeof (mem_block_t);
420

421
    if (block_index < MEM_MNGT_MB0_NB_BLOCKS) {
422
      if (((uint32_t) (leP->data) != (uint32_t) (&(mem->mem_pool0[block_index][0]))) && (leP->pool_id != MEM_MNGT_POOL_ID0)) {
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440
        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
      }
    } else if (block_index < (MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS)) {
      if ((leP->data != &(mem->mem_pool1[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID1)) {
        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
      }
    } else if (block_index < MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS) {
      if ((leP->data != &(mem->mem_pool2[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID2)) {
        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
      }
    } else if (block_index < MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS) {
      if ((leP->data != &(mem->mem_pool3[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID3)) {
        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
      }
    } else if (block_index < MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS) {
      if ((leP->data != &(mem->mem_pool4[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID4)) {
        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
      }
441 442
    } else if (block_index < MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS +
               MEM_MNGT_MB5_NB_BLOCKS) {
443 444 445 446
      if ((leP->data != &(mem->mem_pool5[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID5)) {
        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
      }
    } else if (block_index <
447 448
               MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS +
               MEM_MNGT_MB6_NB_BLOCKS) {
449 450 451 452
      if ((leP->data != &(mem->mem_pool6[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID6)) {
        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
      }
    } else if (block_index <
453 454
               MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS +
               MEM_MNGT_MB6_NB_BLOCKS +
455 456 457 458 459
               MEM_MNGT_MB7_NB_BLOCKS) {
      if ((leP->data != &(mem->mem_pool7[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID7)) {
        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
      }
    } else if (block_index <
460 461
               MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS +
               MEM_MNGT_MB6_NB_BLOCKS +
462 463 464 465 466
               MEM_MNGT_MB7_NB_BLOCKS + MEM_MNGT_MB8_NB_BLOCKS) {
      if ((leP->data != &(mem->mem_pool8[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID8)) {
        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
      }
    } else if (block_index <
467 468
               MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS +
               MEM_MNGT_MB6_NB_BLOCKS +
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483
               MEM_MNGT_MB7_NB_BLOCKS + MEM_MNGT_MB8_NB_BLOCKS + MEM_MNGT_MB9_NB_BLOCKS) {
      if ((leP->data != &(mem->mem_pool9[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID9)) {
        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
      }
    }

  } else {
    msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
  }
}

//-----------------------------------------------------------------------------
void
break_point (void)
{
484
  //-----------------------------------------------------------------------------
485 486 487 488 489
  int             break_var;

  msg ("[BREAK_POINT]\n");
  break_var = 1;
}