OMCompiler/SimulationRuntime/c/gc/omc_alloc.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file belongs to the OpenModelica Run-Time System | ||
| 3 | * | ||
| 4 | * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC), c/o Linköpings | ||
| 5 | * universitet, Department of Computer and Information Science, SE-58183 Linköping, Sweden. All rights | ||
| 6 | * reserved. | ||
| 7 | * | ||
| 8 | * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE | ||
| 9 | * AGPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8. ANY | ||
| 10 | * USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S | ||
| 11 | * ACCEPTANCE OF THE BSD NEW LICENSE OR THE OSMC PUBLIC LICENSE OR THE AGPL | ||
| 12 | * VERSION 3, ACCORDING TO RECIPIENTS CHOICE. | ||
| 13 | * | ||
| 14 | * The OpenModelica software and the OSMC (Open Source Modelica Consortium) Public License | ||
| 15 | * (OSMC-PL) are obtained from OSMC, either from the above address, from the URLs: | ||
| 16 | * http://www.openmodelica.org or https://github.com/OpenModelica/ or | ||
| 17 | * http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica distribution. GNU | ||
| 18 | * AGPL version 3 is obtained from: https://www.gnu.org/licenses/licenses.html#GPL. The BSD NEW | ||
| 19 | * License is obtained from: http://www.opensource.org/licenses/BSD-3-Clause. | ||
| 20 | * | ||
| 21 | * This program is distributed WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY | ||
| 23 | * SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF | ||
| 24 | * OSMC-PL. | ||
| 25 | * | ||
| 26 | */ | ||
| 27 | |||
| 28 | |||
| 29 | /* The typed element allocators the array code calls; the heap itself is | ||
| 30 | gc/omc_rc.c. */ | ||
| 31 | |||
| 32 | #include "../omc_simulation_settings.h" | ||
| 33 | #define OMC_NO_GC_MAPPING | ||
| 34 | #include "omc_gc.h" | ||
| 35 | #include <string.h> | ||
| 36 | |||
| 37 | #if defined(__cplusplus) | ||
| 38 | extern "C" { | ||
| 39 | #endif | ||
| 40 | |||
| 41 | /* allocates n reals */ | ||
| 42 | 30196653 | modelica_real* real_alloc(int n) | |
| 43 | { | ||
| 44 | 30196653 | return (modelica_real*) omc_alloc_interface.malloc_atomic(n*sizeof(modelica_real)); | |
| 45 | } | ||
| 46 | |||
| 47 | /* allocates n integers */ | ||
| 48 | 680210 | modelica_integer* integer_alloc(int n) | |
| 49 | { | ||
| 50 | 680210 | return (modelica_integer*) omc_alloc_interface.malloc_atomic(n*sizeof(modelica_integer)); | |
| 51 | } | ||
| 52 | |||
| 53 | /* allocates n strings */ | ||
| 54 | 1945 | modelica_string* string_alloc(int n) | |
| 55 | { | ||
| 56 | 1945 | return (modelica_string*) omc_alloc_interface.malloc(n*sizeof(modelica_string)); | |
| 57 | } | ||
| 58 | |||
| 59 | /* allocates n booleans */ | ||
| 60 | 18096 | modelica_boolean* boolean_alloc(int n) | |
| 61 | { | ||
| 62 | 18096 | return (modelica_boolean*) omc_alloc_interface.malloc_atomic(n*sizeof(modelica_boolean)); | |
| 63 | } | ||
| 64 | |||
| 65 | 76591505 | _index_t* size_alloc(int n) | |
| 66 | { | ||
| 67 | 76591505 | return (_index_t*) omc_alloc_interface.malloc(n*sizeof(_index_t)); | |
| 68 | } | ||
| 69 | |||
| 70 | 149700 | _index_t** index_alloc(int n) | |
| 71 | { | ||
| 72 | 149700 | return (_index_t**) omc_alloc_interface.malloc(n*sizeof(_index_t*)); | |
| 73 | } | ||
| 74 | |||
| 75 | /* allocates n elements of size sze */ | ||
| 76 | 25404976 | void* generic_alloc(int n, size_t sze) | |
| 77 | { | ||
| 78 | 25404976 | return (void*) omc_alloc_interface.malloc(n*sze); | |
| 79 | } | ||
| 80 | |||
| 81 | |||
| 82 | #if defined(__cplusplus) | ||
| 83 | } /* end extern "C" */ | ||
| 84 | #endif | ||
| 85 |