koffi 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (311) hide show
  1. package/ChangeLog.md +6 -0
  2. package/build/qemu/2.1.2/koffi_darwin_arm64.tar.gz +0 -0
  3. package/build/qemu/2.1.2/koffi_darwin_x64.tar.gz +0 -0
  4. package/build/qemu/2.1.2/koffi_freebsd_arm64.tar.gz +0 -0
  5. package/build/qemu/2.1.2/koffi_freebsd_ia32.tar.gz +0 -0
  6. package/build/qemu/2.1.2/koffi_freebsd_x64.tar.gz +0 -0
  7. package/build/qemu/2.1.2/koffi_linux_arm32hf.tar.gz +0 -0
  8. package/build/qemu/2.1.2/koffi_linux_arm64.tar.gz +0 -0
  9. package/build/qemu/2.1.2/koffi_linux_ia32.tar.gz +0 -0
  10. package/build/qemu/2.1.2/koffi_linux_riscv64hf64.tar.gz +0 -0
  11. package/build/qemu/2.1.2/koffi_linux_x64.tar.gz +0 -0
  12. package/build/qemu/2.1.2/koffi_openbsd_ia32.tar.gz +0 -0
  13. package/build/qemu/2.1.2/koffi_openbsd_x64.tar.gz +0 -0
  14. package/build/qemu/2.1.2/koffi_win32_arm64.tar.gz +0 -0
  15. package/build/qemu/2.1.2/koffi_win32_ia32.tar.gz +0 -0
  16. package/build/qemu/2.1.2/koffi_win32_x64.tar.gz +0 -0
  17. package/doc/templates/badges.html +3 -0
  18. package/package.json +2 -2
  19. package/src/abi_arm64.cc +35 -1
  20. package/src/abi_x64_win.cc +2 -8
  21. package/src/abi_x86.cc +1 -7
  22. package/src/ffi.hh +1 -1
  23. package/src/util.hh +6 -0
  24. package/test/raylib.js +37 -5
  25. package/vendor/libcc/libcc.cc +430 -196
  26. package/vendor/libcc/libcc.hh +1417 -1283
  27. package/vendor/raylib/BINDINGS.md +87 -70
  28. package/vendor/raylib/CHANGELOG +263 -50
  29. package/vendor/raylib/CMakeLists.txt +12 -0
  30. package/vendor/raylib/CMakeOptions.txt +8 -1
  31. package/vendor/raylib/CONVENTIONS.md +2 -3
  32. package/vendor/raylib/FAQ.md +137 -0
  33. package/vendor/raylib/HISTORY.md +62 -29
  34. package/vendor/raylib/LICENSE +1 -1
  35. package/vendor/raylib/README.md +22 -17
  36. package/vendor/raylib/ROADMAP.md +8 -7
  37. package/vendor/raylib/cmake/CompileDefinitions.cmake +19 -15
  38. package/vendor/raylib/cmake/GlfwImport.cmake +2 -0
  39. package/vendor/raylib/cmake/LibraryConfigurations.cmake +22 -16
  40. package/vendor/raylib/cmake/raylib-config.cmake +52 -49
  41. package/vendor/raylib/examples/CMakeLists.txt +14 -9
  42. package/vendor/raylib/examples/Makefile +112 -125
  43. package/vendor/raylib/examples/Makefile.Android +1 -1
  44. package/vendor/raylib/examples/Makefile.Web +145 -158
  45. package/vendor/raylib/examples/README.md +141 -141
  46. package/vendor/raylib/examples/audio/audio_module_playing.c +9 -4
  47. package/vendor/raylib/examples/audio/audio_multichannel_sound.c +8 -3
  48. package/vendor/raylib/examples/audio/audio_music_stream.c +16 -11
  49. package/vendor/raylib/examples/audio/audio_raw_stream.c +57 -9
  50. package/vendor/raylib/examples/audio/audio_sound_loading.c +8 -3
  51. package/vendor/raylib/examples/audio/audio_stream_effects.c +179 -0
  52. package/vendor/raylib/examples/audio/audio_stream_effects.png +0 -0
  53. package/vendor/raylib/examples/build.zig +17 -6
  54. package/vendor/raylib/examples/core/core_2d_camera.c +8 -4
  55. package/vendor/raylib/examples/core/core_2d_camera_mouse_zoom.c +105 -0
  56. package/vendor/raylib/examples/core/core_2d_camera_mouse_zoom.png +0 -0
  57. package/vendor/raylib/examples/core/core_2d_camera_platformer.c +11 -6
  58. package/vendor/raylib/examples/core/core_3d_camera_first_person.c +9 -4
  59. package/vendor/raylib/examples/core/core_3d_camera_free.c +9 -4
  60. package/vendor/raylib/examples/core/core_3d_camera_mode.c +8 -3
  61. package/vendor/raylib/examples/core/core_3d_picking.c +9 -4
  62. package/vendor/raylib/examples/core/core_basic_screen_manager.c +9 -7
  63. package/vendor/raylib/examples/core/core_basic_window.c +8 -3
  64. package/vendor/raylib/examples/core/core_basic_window_web.c +13 -11
  65. package/vendor/raylib/examples/core/core_custom_frame_control.c +9 -4
  66. package/vendor/raylib/examples/core/core_custom_logging.c +12 -8
  67. package/vendor/raylib/examples/core/core_drop_files.c +20 -12
  68. package/vendor/raylib/examples/core/core_input_gamepad.c +20 -15
  69. package/vendor/raylib/examples/core/core_input_gestures.c +19 -15
  70. package/vendor/raylib/examples/core/core_input_keys.c +8 -3
  71. package/vendor/raylib/examples/core/core_input_mouse.c +8 -3
  72. package/vendor/raylib/examples/core/core_input_mouse_wheel.c +8 -3
  73. package/vendor/raylib/examples/core/core_input_multitouch.c +8 -3
  74. package/vendor/raylib/examples/core/core_loading_thread.c +10 -6
  75. package/vendor/raylib/examples/core/core_random_values.c +8 -3
  76. package/vendor/raylib/examples/core/core_scissor_test.c +8 -3
  77. package/vendor/raylib/examples/core/core_smooth_pixelperfect.c +9 -4
  78. package/vendor/raylib/examples/core/core_split_screen.c +8 -3
  79. package/vendor/raylib/examples/core/core_storage_values.c +109 -3
  80. package/vendor/raylib/examples/core/core_vr_simulator.c +15 -7
  81. package/vendor/raylib/examples/core/core_window_flags.c +8 -3
  82. package/vendor/raylib/examples/core/core_window_letterbox.c +13 -18
  83. package/vendor/raylib/examples/core/core_window_should_close.c +77 -0
  84. package/vendor/raylib/examples/core/core_window_should_close.png +0 -0
  85. package/vendor/raylib/examples/core/core_world_screen.c +9 -4
  86. package/vendor/raylib/examples/examples_template.c +8 -3
  87. package/vendor/raylib/examples/models/models_animation.c +11 -7
  88. package/vendor/raylib/examples/models/models_billboard.c +9 -4
  89. package/vendor/raylib/examples/models/models_box_collisions.c +8 -3
  90. package/vendor/raylib/examples/models/models_cubicmap.c +9 -4
  91. package/vendor/raylib/examples/models/models_first_person_maze.c +9 -4
  92. package/vendor/raylib/examples/models/models_geometric_shapes.c +8 -3
  93. package/vendor/raylib/examples/models/models_heightmap.c +9 -4
  94. package/vendor/raylib/examples/models/models_loading.c +21 -17
  95. package/vendor/raylib/examples/models/models_loading_gltf.c +15 -41
  96. package/vendor/raylib/examples/models/models_loading_vox.c +9 -4
  97. package/vendor/raylib/examples/models/models_mesh_generation.c +71 -58
  98. package/vendor/raylib/examples/models/models_mesh_picking.c +25 -7
  99. package/vendor/raylib/examples/models/models_orthographic_projection.c +8 -5
  100. package/vendor/raylib/examples/models/models_rlgl_solar_system.c +6 -4
  101. package/vendor/raylib/examples/models/models_skybox.c +16 -12
  102. package/vendor/raylib/examples/models/models_waving_cubes.c +9 -4
  103. package/vendor/raylib/examples/models/models_yaw_pitch_roll.c +12 -7
  104. package/vendor/raylib/examples/models/resources/LICENSE.md +9 -10
  105. package/vendor/raylib/examples/models/resources/models/gltf/LICENSE +2 -23
  106. package/vendor/raylib/examples/models/resources/models/gltf/{raylib_32x32.glb → raylib_logo_3d.glb} +0 -0
  107. package/vendor/raylib/examples/models/resources/models/gltf/robot.blend +0 -0
  108. package/vendor/raylib/examples/models/resources/models/gltf/robot.glb +0 -0
  109. package/vendor/raylib/examples/others/easings_testbed.c +10 -8
  110. package/vendor/raylib/examples/others/easings_testbed.png +0 -0
  111. package/vendor/raylib/examples/others/embedded_files_loading.c +10 -5
  112. package/vendor/raylib/examples/others/embedded_files_loading.png +0 -0
  113. package/vendor/raylib/examples/others/raylib_opengl_interop.c +10 -6
  114. package/vendor/raylib/{src/extras/easings.h → examples/others/reasings.h} +38 -38
  115. package/vendor/raylib/examples/others/rlgl_compute_shader.c +21 -20
  116. package/vendor/raylib/examples/others/rlgl_compute_shader.png +0 -0
  117. package/vendor/raylib/examples/others/rlgl_standalone.c +4 -4
  118. package/vendor/raylib/examples/others/rlgl_standalone.png +0 -0
  119. package/vendor/raylib/examples/raylib_compile_execute.bat +2 -2
  120. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/lighting.fs +1 -1
  121. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/{base_lighting_instanced.vs → lighting_instancing.vs} +2 -2
  122. package/vendor/raylib/examples/shaders/rlights.h +14 -27
  123. package/vendor/raylib/examples/shaders/shaders_basic_lighting.c +24 -26
  124. package/vendor/raylib/examples/shaders/shaders_custom_uniform.c +10 -5
  125. package/vendor/raylib/examples/shaders/shaders_eratosthenes.c +13 -8
  126. package/vendor/raylib/examples/shaders/shaders_fog.c +8 -12
  127. package/vendor/raylib/examples/shaders/shaders_hot_reloading.c +10 -5
  128. package/vendor/raylib/examples/shaders/shaders_julia_set.c +9 -4
  129. package/vendor/raylib/examples/shaders/shaders_mesh_instancing.c +45 -119
  130. package/vendor/raylib/examples/shaders/shaders_model_shader.c +10 -5
  131. package/vendor/raylib/examples/shaders/shaders_multi_sample2d.c +8 -3
  132. package/vendor/raylib/examples/shaders/shaders_palette_switch.c +8 -3
  133. package/vendor/raylib/examples/shaders/shaders_postprocessing.c +9 -4
  134. package/vendor/raylib/examples/shaders/shaders_raymarching.c +14 -11
  135. package/vendor/raylib/examples/shaders/shaders_shapes_textures.c +8 -3
  136. package/vendor/raylib/examples/shaders/shaders_simple_mask.c +10 -5
  137. package/vendor/raylib/examples/shaders/shaders_spotlight.c +10 -6
  138. package/vendor/raylib/examples/shaders/shaders_texture_drawing.c +9 -4
  139. package/vendor/raylib/examples/shaders/shaders_texture_outline.c +8 -3
  140. package/vendor/raylib/examples/shaders/shaders_texture_waves.c +8 -3
  141. package/vendor/raylib/{src/extras → examples/shapes}/raygui.h +1290 -1141
  142. package/vendor/raylib/examples/{others/easings.h → shapes/reasings.h} +40 -40
  143. package/vendor/raylib/examples/shapes/shapes_basic_shapes.c +8 -3
  144. package/vendor/raylib/examples/shapes/shapes_bouncing_ball.c +8 -3
  145. package/vendor/raylib/examples/shapes/shapes_collision_area.c +10 -4
  146. package/vendor/raylib/examples/shapes/shapes_colors_palette.c +8 -3
  147. package/vendor/raylib/examples/shapes/shapes_draw_circle_sector.c +9 -4
  148. package/vendor/raylib/examples/shapes/shapes_draw_rectangle_rounded.c +9 -4
  149. package/vendor/raylib/examples/shapes/shapes_draw_ring.c +10 -6
  150. package/vendor/raylib/examples/shapes/shapes_easings_ball_anim.c +9 -4
  151. package/vendor/raylib/examples/shapes/shapes_easings_box_anim.c +9 -4
  152. package/vendor/raylib/examples/shapes/shapes_easings_rectangle_array.c +9 -4
  153. package/vendor/raylib/examples/shapes/shapes_following_eyes.c +8 -3
  154. package/vendor/raylib/examples/shapes/shapes_lines_bezier.c +8 -3
  155. package/vendor/raylib/examples/shapes/shapes_logo_raylib.c +8 -3
  156. package/vendor/raylib/examples/shapes/shapes_logo_raylib_anim.c +8 -3
  157. package/vendor/raylib/examples/shapes/shapes_rectangle_scaling.c +14 -5
  158. package/vendor/raylib/examples/shapes/shapes_top_down_lights.c +355 -0
  159. package/vendor/raylib/examples/shapes/shapes_top_down_lights.png +0 -0
  160. package/vendor/raylib/examples/text/resources/DotGothic16-Regular.ttf +0 -0
  161. package/vendor/raylib/examples/text/resources/DotGothic16-Regular_OFL.txt +93 -0
  162. package/vendor/raylib/examples/text/resources/LICENSE.md +1 -1
  163. package/vendor/raylib/examples/text/text_codepoints_loading.c +138 -0
  164. package/vendor/raylib/examples/text/text_codepoints_loading.png +0 -0
  165. package/vendor/raylib/examples/text/text_draw_3d.c +42 -33
  166. package/vendor/raylib/examples/text/text_font_filters.c +14 -11
  167. package/vendor/raylib/examples/text/text_font_loading.c +9 -4
  168. package/vendor/raylib/examples/text/text_font_sdf.c +9 -4
  169. package/vendor/raylib/examples/text/text_font_spritefont.c +12 -6
  170. package/vendor/raylib/examples/text/text_format_text.c +8 -3
  171. package/vendor/raylib/examples/text/text_input_box.c +8 -3
  172. package/vendor/raylib/examples/text/text_raylib_fonts.c +9 -4
  173. package/vendor/raylib/examples/text/text_rectangle_bounds.c +9 -5
  174. package/vendor/raylib/examples/text/text_unicode.c +9 -7
  175. package/vendor/raylib/examples/text/text_writing_anim.c +8 -3
  176. package/vendor/raylib/examples/textures/resources/scarfy_run.gif +0 -0
  177. package/vendor/raylib/examples/textures/textures_background_scrolling.c +8 -3
  178. package/vendor/raylib/examples/textures/textures_blend_modes.c +8 -3
  179. package/vendor/raylib/examples/textures/textures_bunnymark.c +8 -3
  180. package/vendor/raylib/examples/textures/textures_draw_tiled.c +14 -10
  181. package/vendor/raylib/examples/textures/textures_fog_of_war.c +154 -0
  182. package/vendor/raylib/examples/textures/textures_fog_of_war.png +0 -0
  183. package/vendor/raylib/examples/textures/textures_gif_player.c +121 -0
  184. package/vendor/raylib/examples/textures/textures_gif_player.png +0 -0
  185. package/vendor/raylib/examples/textures/textures_image_drawing.c +8 -3
  186. package/vendor/raylib/examples/textures/textures_image_generation.c +8 -3
  187. package/vendor/raylib/examples/textures/textures_image_loading.c +8 -3
  188. package/vendor/raylib/examples/textures/textures_image_processing.c +8 -3
  189. package/vendor/raylib/examples/textures/textures_image_text.c +8 -3
  190. package/vendor/raylib/examples/textures/textures_logo_raylib.c +8 -3
  191. package/vendor/raylib/examples/textures/textures_mouse_painting.c +9 -4
  192. package/vendor/raylib/examples/textures/textures_npatch_drawing.c +8 -3
  193. package/vendor/raylib/examples/textures/textures_particles_blending.c +8 -3
  194. package/vendor/raylib/examples/textures/textures_polygon.c +9 -5
  195. package/vendor/raylib/examples/textures/textures_raw_data.c +8 -3
  196. package/vendor/raylib/examples/textures/{textures_rectangle.c → textures_sprite_anim.c} +11 -5
  197. package/vendor/raylib/examples/textures/{textures_rectangle.png → textures_sprite_anim.png} +0 -0
  198. package/vendor/raylib/examples/textures/textures_sprite_button.c +8 -3
  199. package/vendor/raylib/examples/textures/textures_sprite_explosion.c +8 -3
  200. package/vendor/raylib/examples/textures/textures_srcrec_dstrec.c +8 -3
  201. package/vendor/raylib/examples/textures/textures_to_image.c +8 -3
  202. package/vendor/raylib/parser/LICENSE +1 -1
  203. package/vendor/raylib/parser/Makefile +28 -0
  204. package/vendor/raylib/parser/README.md +49 -5
  205. package/vendor/raylib/parser/output/raylib_api.json +10717 -0
  206. package/vendor/raylib/parser/output/raylib_api.lua +7435 -0
  207. package/vendor/raylib/parser/{raylib_api.txt → output/raylib_api.txt} +1371 -824
  208. package/vendor/raylib/parser/{raylib_api.xml → output/raylib_api.xml} +827 -595
  209. package/vendor/raylib/parser/raylib_parser.c +1174 -196
  210. package/vendor/raylib/projects/4coder/Makefile +2 -4
  211. package/vendor/raylib/projects/4coder/main.c +0 -1
  212. package/vendor/raylib/projects/CMake/CMakeLists.txt +13 -16
  213. package/vendor/raylib/projects/CMake/README.md +27 -0
  214. package/vendor/raylib/projects/CMake/core_basic_window.c +52 -31
  215. package/vendor/raylib/projects/CodeBlocks/README.md +4 -4
  216. package/vendor/raylib/projects/Geany/core_basic_window.c +1 -1
  217. package/vendor/raylib/projects/Notepad++/c_raylib.xml +168 -128
  218. package/vendor/raylib/projects/Notepad++/npes_saved_tcc.txt +0 -0
  219. package/vendor/raylib/projects/Notepad++/npes_saved_w64devkit.txt +0 -0
  220. package/vendor/raylib/projects/Notepad++/npes_saved_zig.txt +0 -0
  221. package/vendor/raylib/projects/Notepad++/raylib_npp_parser/raylib_npp.xml +168 -84
  222. package/vendor/raylib/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h +67 -51
  223. package/vendor/raylib/projects/README.md +1 -1
  224. package/vendor/raylib/projects/VSCode/.vscode/c_cpp_properties.json +1 -1
  225. package/vendor/raylib/projects/VSCode/Makefile +8 -11
  226. package/vendor/raylib/projects/VSCode/main.c +53 -26
  227. package/vendor/raylib/projects/VSCode/resources/LICENSE +1 -0
  228. package/vendor/raylib/projects/scripts/build-linux.sh +6 -6
  229. package/vendor/raylib/projects/scripts/build-osx.sh +6 -6
  230. package/vendor/raylib/projects/scripts/build-rpi.sh +6 -6
  231. package/vendor/raylib/projects/scripts/build-windows.bat +2 -2
  232. package/vendor/raylib/src/CMakeLists.txt +6 -7
  233. package/vendor/raylib/src/Makefile +209 -103
  234. package/vendor/raylib/src/build.zig +56 -20
  235. package/vendor/raylib/src/config.h +32 -27
  236. package/vendor/raylib/src/external/cgltf.h +342 -104
  237. package/vendor/raylib/src/external/dr_wav.h +487 -225
  238. package/vendor/raylib/src/external/glfw/src/posix_time.c +1 -3
  239. package/vendor/raylib/src/external/glfw/src/wl_init.c +1 -3
  240. package/vendor/raylib/src/external/jar_xm.h +2 -1
  241. package/vendor/raylib/src/external/miniaudio.h +62251 -42061
  242. package/vendor/raylib/src/external/qoi.h +671 -0
  243. package/vendor/raylib/src/external/stb_vorbis.h +1 -1
  244. package/vendor/raylib/src/external/vox_loader.h +30 -25
  245. package/vendor/raylib/src/minshell.html +82 -0
  246. package/vendor/raylib/src/raudio.c +359 -201
  247. package/vendor/raylib/src/raylib.dll.rc +5 -5
  248. package/vendor/raylib/src/raylib.dll.rc.data +0 -0
  249. package/vendor/raylib/src/raylib.h +95 -63
  250. package/vendor/raylib/src/raylib.rc +5 -5
  251. package/vendor/raylib/src/raylib.rc.data +0 -0
  252. package/vendor/raylib/src/raymath.h +391 -133
  253. package/vendor/raylib/src/rcamera.h +32 -41
  254. package/vendor/raylib/src/rcore.c +775 -471
  255. package/vendor/raylib/src/rgestures.h +5 -5
  256. package/vendor/raylib/src/rglfw.c +3 -3
  257. package/vendor/raylib/src/rlgl.h +184 -144
  258. package/vendor/raylib/src/rmodels.c +207 -144
  259. package/vendor/raylib/src/rshapes.c +105 -47
  260. package/vendor/raylib/src/rtext.c +255 -38
  261. package/vendor/raylib/src/rtextures.c +167 -71
  262. package/vendor/raylib/src/shell.html +63 -63
  263. package/vendor/raylib/src/utils.c +49 -3
  264. package/vendor/raylib/src/utils.h +3 -3
  265. package/build/qemu/2.1.1/koffi_darwin_arm64.tar.gz +0 -0
  266. package/build/qemu/2.1.1/koffi_darwin_x64.tar.gz +0 -0
  267. package/build/qemu/2.1.1/koffi_freebsd_arm64.tar.gz +0 -0
  268. package/build/qemu/2.1.1/koffi_freebsd_ia32.tar.gz +0 -0
  269. package/build/qemu/2.1.1/koffi_freebsd_x64.tar.gz +0 -0
  270. package/build/qemu/2.1.1/koffi_linux_arm32hf.tar.gz +0 -0
  271. package/build/qemu/2.1.1/koffi_linux_arm64.tar.gz +0 -0
  272. package/build/qemu/2.1.1/koffi_linux_ia32.tar.gz +0 -0
  273. package/build/qemu/2.1.1/koffi_linux_riscv64hf64.tar.gz +0 -0
  274. package/build/qemu/2.1.1/koffi_linux_x64.tar.gz +0 -0
  275. package/build/qemu/2.1.1/koffi_openbsd_ia32.tar.gz +0 -0
  276. package/build/qemu/2.1.1/koffi_openbsd_x64.tar.gz +0 -0
  277. package/build/qemu/2.1.1/koffi_win32_arm64.tar.gz +0 -0
  278. package/build/qemu/2.1.1/koffi_win32_ia32.tar.gz +0 -0
  279. package/build/qemu/2.1.1/koffi_win32_x64.tar.gz +0 -0
  280. package/vendor/raylib/CONTRIBUTORS.md +0 -63
  281. package/vendor/raylib/SPONSORS.md +0 -68
  282. package/vendor/raylib/examples/core/core_quat_conversion.c +0 -132
  283. package/vendor/raylib/examples/core/core_quat_conversion.png +0 -0
  284. package/vendor/raylib/examples/models/resources/models/gltf/AnimatedMorphCube.glb +0 -0
  285. package/vendor/raylib/examples/models/resources/models/gltf/AnimatedTriangle.gltf +0 -118
  286. package/vendor/raylib/examples/models/resources/models/gltf/BoxAnimated.glb +0 -0
  287. package/vendor/raylib/examples/models/resources/models/gltf/girl.glb +0 -0
  288. package/vendor/raylib/examples/models/resources/models/gltf/rigged_figure.glb +0 -0
  289. package/vendor/raylib/examples/models/resources/models/gltf/vertex_colored_object.glb +0 -0
  290. package/vendor/raylib/examples/models/resources/models/iqm/vertex_colored_object.iqm +0 -0
  291. package/vendor/raylib/examples/models/rlights.h +0 -183
  292. package/vendor/raylib/examples/others/raudio_standalone.c +0 -152
  293. package/vendor/raylib/examples/others/resources/audio/country.mp3 +0 -0
  294. package/vendor/raylib/examples/others/resources/audio/target.ogg +0 -0
  295. package/vendor/raylib/examples/others/resources/audio/weird.wav +0 -0
  296. package/vendor/raylib/examples/physics/physics_demo.c +0 -128
  297. package/vendor/raylib/examples/physics/physics_demo.png +0 -0
  298. package/vendor/raylib/examples/physics/physics_friction.c +0 -142
  299. package/vendor/raylib/examples/physics/physics_friction.png +0 -0
  300. package/vendor/raylib/examples/physics/physics_movement.c +0 -128
  301. package/vendor/raylib/examples/physics/physics_movement.png +0 -0
  302. package/vendor/raylib/examples/physics/physics_restitution.c +0 -129
  303. package/vendor/raylib/examples/physics/physics_restitution.png +0 -0
  304. package/vendor/raylib/examples/physics/physics_shatter.c +0 -111
  305. package/vendor/raylib/examples/physics/physics_shatter.png +0 -0
  306. package/vendor/raylib/parser/raylib_api.json +0 -6668
  307. package/vendor/raylib/projects/VS2019/raylib/raylib.rc +0 -0
  308. package/vendor/raylib/projects/VS2019/raylib/resource.h +0 -14
  309. package/vendor/raylib/src/extras/physac.h +0 -1977
  310. package/vendor/raylib/src/extras/rmem.h +0 -751
  311. package/vendor/raylib/src/raudio.h +0 -198
@@ -1,751 +0,0 @@
1
- /**********************************************************************************************
2
- *
3
- * rmem - raylib memory pool and objects pool
4
- *
5
- * A quick, efficient, and minimal free list and arena-based allocator
6
- *
7
- * PURPOSE:
8
- * - A quicker, efficient memory allocator alternative to 'malloc' and friends.
9
- * - Reduce the possibilities of memory leaks for beginner developers using Raylib.
10
- * - Being able to flexibly range check memory if necessary.
11
- *
12
- * CONFIGURATION:
13
- *
14
- * #define RMEM_IMPLEMENTATION
15
- * Generates the implementation of the library into the included file.
16
- * If not defined, the library is in header only mode and can be included in other headers
17
- * or source files without problems. But only ONE file should hold the implementation.
18
- *
19
- *
20
- * LICENSE: zlib/libpng
21
- *
22
- * Copyright (c) 2019 Kevin 'Assyrianic' Yonan (@assyrianic) and reviewed by Ramon Santamaria (@raysan5)
23
- *
24
- * This software is provided "as-is", without any express or implied warranty. In no event
25
- * will the authors be held liable for any damages arising from the use of this software.
26
- *
27
- * Permission is granted to anyone to use this software for any purpose, including commercial
28
- * applications, and to alter it and redistribute it freely, subject to the following restrictions:
29
- *
30
- * 1. The origin of this software must not be misrepresented; you must not claim that you
31
- * wrote the original software. If you use this software in a product, an acknowledgment
32
- * in the product documentation would be appreciated but is not required.
33
- *
34
- * 2. Altered source versions must be plainly marked as such, and must not be misrepresented
35
- * as being the original software.
36
- *
37
- * 3. This notice may not be removed or altered from any source distribution.
38
- *
39
- **********************************************************************************************/
40
-
41
- #ifndef RMEM_H
42
- #define RMEM_H
43
-
44
- #include <inttypes.h>
45
- #include <stdbool.h>
46
-
47
- //----------------------------------------------------------------------------------
48
- // Defines and Macros
49
- //----------------------------------------------------------------------------------
50
- #if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED)
51
- #define RMEMAPI __declspec(dllexport) // We are building library as a Win32 shared library (.dll)
52
- #elif defined(_WIN32) && defined(USE_LIBTYPE_SHARED)
53
- #define RMEMAPI __declspec(dllimport) // We are using library as a Win32 shared library (.dll)
54
- #else
55
- #define RMEMAPI // We are building or using library as a static library (or Linux shared library)
56
- #endif
57
-
58
- #define RMEM_VERSION "v1.3" // changelog at bottom of header.
59
-
60
- //----------------------------------------------------------------------------------
61
- // Types and Structures Definition
62
- //----------------------------------------------------------------------------------
63
-
64
- // Memory Pool
65
- typedef struct MemNode MemNode;
66
- struct MemNode {
67
- size_t size;
68
- MemNode *next, *prev;
69
- };
70
-
71
- // Freelist implementation
72
- typedef struct AllocList {
73
- MemNode *head, *tail;
74
- size_t len;
75
- } AllocList;
76
-
77
- // Arena allocator.
78
- typedef struct Arena {
79
- uintptr_t mem, offs;
80
- size_t size;
81
- } Arena;
82
-
83
-
84
- enum {
85
- MEMPOOL_BUCKET_SIZE = 8,
86
- MEMPOOL_BUCKET_BITS = (sizeof(uintptr_t) >> 1) + 1,
87
- MEM_SPLIT_THRESHOLD = sizeof(uintptr_t) * 4
88
- };
89
-
90
- typedef struct MemPool {
91
- AllocList large, buckets[MEMPOOL_BUCKET_SIZE];
92
- Arena arena;
93
- } MemPool;
94
-
95
-
96
- // Object Pool
97
- typedef struct ObjPool {
98
- uintptr_t mem, offs;
99
- size_t objSize, freeBlocks, memSize;
100
- } ObjPool;
101
-
102
-
103
- // Double-Ended Stack aka Deque
104
- typedef struct BiStack {
105
- uintptr_t mem, front, back;
106
- size_t size;
107
- } BiStack;
108
-
109
-
110
- #if defined(__cplusplus)
111
- extern "C" { // Prevents name mangling of functions
112
- #endif
113
-
114
- //------------------------------------------------------------------------------------
115
- // Functions Declaration - Memory Pool
116
- //------------------------------------------------------------------------------------
117
- RMEMAPI MemPool CreateMemPool(size_t bytes);
118
- RMEMAPI MemPool CreateMemPoolFromBuffer(void *buf, size_t bytes);
119
- RMEMAPI void DestroyMemPool(MemPool *mempool);
120
-
121
- RMEMAPI void *MemPoolAlloc(MemPool *mempool, size_t bytes);
122
- RMEMAPI void *MemPoolRealloc(MemPool *mempool, void *ptr, size_t bytes);
123
- RMEMAPI void MemPoolFree(MemPool *mempool, void *ptr);
124
- RMEMAPI void MemPoolCleanUp(MemPool *mempool, void **ptrref);
125
- RMEMAPI void MemPoolReset(MemPool *mempool);
126
- RMEMAPI size_t GetMemPoolFreeMemory(const MemPool mempool);
127
-
128
- //------------------------------------------------------------------------------------
129
- // Functions Declaration - Object Pool
130
- //------------------------------------------------------------------------------------
131
- RMEMAPI ObjPool CreateObjPool(size_t objsize, size_t len);
132
- RMEMAPI ObjPool CreateObjPoolFromBuffer(void *buf, size_t objsize, size_t len);
133
- RMEMAPI void DestroyObjPool(ObjPool *objpool);
134
-
135
- RMEMAPI void *ObjPoolAlloc(ObjPool *objpool);
136
- RMEMAPI void ObjPoolFree(ObjPool *objpool, void *ptr);
137
- RMEMAPI void ObjPoolCleanUp(ObjPool *objpool, void **ptrref);
138
-
139
- //------------------------------------------------------------------------------------
140
- // Functions Declaration - Double-Ended Stack
141
- //------------------------------------------------------------------------------------
142
- RMEMAPI BiStack CreateBiStack(size_t len);
143
- RMEMAPI BiStack CreateBiStackFromBuffer(void *buf, size_t len);
144
- RMEMAPI void DestroyBiStack(BiStack *destack);
145
-
146
- RMEMAPI void *BiStackAllocFront(BiStack *destack, size_t len);
147
- RMEMAPI void *BiStackAllocBack(BiStack *destack, size_t len);
148
-
149
- RMEMAPI void BiStackResetFront(BiStack *destack);
150
- RMEMAPI void BiStackResetBack(BiStack *destack);
151
- RMEMAPI void BiStackResetAll(BiStack *destack);
152
-
153
- RMEMAPI intptr_t BiStackMargins(BiStack destack);
154
-
155
- #ifdef __cplusplus
156
- }
157
- #endif
158
-
159
- #endif // RMEM_H
160
-
161
- /***********************************************************************************
162
- *
163
- * RMEM IMPLEMENTATION
164
- *
165
- ************************************************************************************/
166
-
167
- #if defined(RMEM_IMPLEMENTATION)
168
-
169
- #include <stdio.h> // Required for:
170
- #include <stdlib.h> // Required for:
171
- #include <string.h> // Required for:
172
-
173
- //----------------------------------------------------------------------------------
174
- // Defines and Macros
175
- //----------------------------------------------------------------------------------
176
-
177
- // Make sure restrict type qualifier for pointers is defined
178
- // NOTE: Not supported by C++, it is a C only keyword
179
- #if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) || defined(_MSC_VER)
180
- #ifndef restrict
181
- #define restrict __restrict
182
- #endif
183
- #endif
184
-
185
- //----------------------------------------------------------------------------------
186
- // Global Variables Definition
187
- //----------------------------------------------------------------------------------
188
- // ...
189
-
190
- //----------------------------------------------------------------------------------
191
- // Module specific Functions Declaration
192
- //----------------------------------------------------------------------------------
193
- static inline size_t __AlignSize(const size_t size, const size_t align)
194
- {
195
- return (size + (align - 1)) & -align;
196
- }
197
-
198
- static MemNode *__SplitMemNode(MemNode *const node, const size_t bytes)
199
- {
200
- uintptr_t n = ( uintptr_t )node;
201
- MemNode *const r = ( MemNode* )(n + (node->size - bytes));
202
- node->size -= bytes;
203
- r->size = bytes;
204
- return r;
205
- }
206
-
207
- static void __InsertMemNodeBefore(AllocList *const list, MemNode *const insert, MemNode *const curr)
208
- {
209
- insert->next = curr;
210
- if (curr->prev==NULL) list->head = insert;
211
- else
212
- {
213
- insert->prev = curr->prev;
214
- curr->prev->next = insert;
215
- }
216
- curr->prev = insert;
217
- }
218
-
219
- static void __ReplaceMemNode(MemNode *const old, MemNode *const replace)
220
- {
221
- replace->prev = old->prev;
222
- replace->next = old->next;
223
- if( old->prev != NULL )
224
- old->prev->next = replace;
225
- if( old->next != NULL )
226
- old->next->prev = replace;
227
- }
228
-
229
-
230
- static MemNode *__RemoveMemNode(AllocList *const list, MemNode *const node)
231
- {
232
- if (node->prev != NULL) node->prev->next = node->next;
233
- else
234
- {
235
- list->head = node->next;
236
- if (list->head != NULL) list->head->prev = NULL;
237
- else list->tail = NULL;
238
- }
239
-
240
- if (node->next != NULL) node->next->prev = node->prev;
241
- else
242
- {
243
- list->tail = node->prev;
244
- if (list->tail != NULL) list->tail->next = NULL;
245
- else list->head = NULL;
246
- }
247
- list->len--;
248
- return node;
249
- }
250
-
251
- static MemNode *__FindMemNode(AllocList *const list, const size_t bytes)
252
- {
253
- for (MemNode *node = list->head; node != NULL; node = node->next)
254
- {
255
- if (node->size < bytes) continue;
256
- // close in size - reduce fragmentation by not splitting.
257
- else if (node->size <= bytes + MEM_SPLIT_THRESHOLD) return __RemoveMemNode(list, node);
258
- else return __SplitMemNode(node, bytes);
259
- }
260
- return NULL;
261
- }
262
-
263
- static void __InsertMemNode(MemPool *const mempool, AllocList *const list, MemNode *const node, const bool is_bucket)
264
- {
265
- if (list->head == NULL)
266
- {
267
- list->head = node;
268
- list->len++;
269
- }
270
- else
271
- {
272
- for (MemNode *iter = list->head; iter != NULL; iter = iter->next)
273
- {
274
- if (( uintptr_t )iter == mempool->arena.offs)
275
- {
276
- mempool->arena.offs += iter->size;
277
- __RemoveMemNode(list, iter);
278
- iter = list->head;
279
- if (iter == NULL) {
280
- list->head = node;
281
- return;
282
- }
283
- }
284
- const uintptr_t inode = ( uintptr_t )node;
285
- const uintptr_t iiter = ( uintptr_t )iter;
286
- const uintptr_t iter_end = iiter + iter->size;
287
- const uintptr_t node_end = inode + node->size;
288
- if (iter==node) return;
289
- else if (iter < node)
290
- {
291
- // node was coalesced prior.
292
- if (iter_end > inode) return;
293
- else if (iter_end==inode && !is_bucket)
294
- {
295
- // if we can coalesce, do so.
296
- iter->size += node->size;
297
- return;
298
- }
299
- else if (iter->next == NULL)
300
- {
301
- // we reached the end of the free list -> append the node
302
- iter->next = node;
303
- node->prev = iter;
304
- list->len++;
305
- return;
306
- }
307
- }
308
- else if (iter > node)
309
- {
310
- // Address sort, lowest to highest aka ascending order.
311
- if (iiter < node_end) return;
312
- else if (iter==list->head && !is_bucket)
313
- {
314
- if (iter_end==inode) iter->size += node->size;
315
- else if (node_end==iiter)
316
- {
317
- node->size += list->head->size;
318
- node->next = list->head->next;
319
- node->prev = NULL;
320
- list->head = node;
321
- }
322
- else
323
- {
324
- node->next = iter;
325
- node->prev = NULL;
326
- iter->prev = node;
327
- list->head = node;
328
- list->len++;
329
- }
330
- return;
331
- }
332
- else if (iter_end==inode && !is_bucket)
333
- {
334
- // if we can coalesce, do so.
335
- iter->size += node->size;
336
- return;
337
- }
338
- else
339
- {
340
- __InsertMemNodeBefore(list, node, iter);
341
- list->len++;
342
- return;
343
- }
344
- }
345
- }
346
- }
347
- }
348
-
349
- //----------------------------------------------------------------------------------
350
- // Module Functions Definition - Memory Pool
351
- //----------------------------------------------------------------------------------
352
-
353
- MemPool CreateMemPool(const size_t size)
354
- {
355
- MemPool mempool = { 0 };
356
-
357
- if (size == 0) return mempool;
358
- else
359
- {
360
- // Align the mempool size to at least the size of an alloc node.
361
- uint8_t *const restrict buf = malloc(size*sizeof *buf);
362
- if (buf==NULL) return mempool;
363
- else
364
- {
365
- mempool.arena.size = size;
366
- mempool.arena.mem = ( uintptr_t )buf;
367
- mempool.arena.offs = mempool.arena.mem + mempool.arena.size;
368
- return mempool;
369
- }
370
- }
371
- }
372
-
373
- MemPool CreateMemPoolFromBuffer(void *const restrict buf, const size_t size)
374
- {
375
- MemPool mempool = { 0 };
376
- if ((size == 0) || (buf == NULL) || (size <= sizeof(MemNode))) return mempool;
377
- else
378
- {
379
- mempool.arena.size = size;
380
- mempool.arena.mem = ( uintptr_t )buf;
381
- mempool.arena.offs = mempool.arena.mem + mempool.arena.size;
382
- return mempool;
383
- }
384
- }
385
-
386
- void DestroyMemPool(MemPool *const restrict mempool)
387
- {
388
- if (mempool->arena.mem == 0) return;
389
- else
390
- {
391
- void *const restrict ptr = ( void* )mempool->arena.mem;
392
- free(ptr);
393
- *mempool = (MemPool){ 0 };
394
- }
395
- }
396
-
397
- void *MemPoolAlloc(MemPool *const mempool, const size_t size)
398
- {
399
- if ((size == 0) || (size > mempool->arena.size)) return NULL;
400
- else
401
- {
402
- MemNode *new_mem = NULL;
403
- const size_t ALLOC_SIZE = __AlignSize(size + sizeof *new_mem, sizeof(intptr_t));
404
- const size_t BUCKET_SLOT = (ALLOC_SIZE >> MEMPOOL_BUCKET_BITS) - 1;
405
-
406
- // If the size is small enough, let's check if our buckets has a fitting memory block.
407
- if (BUCKET_SLOT < MEMPOOL_BUCKET_SIZE)
408
- {
409
- new_mem = __FindMemNode(&mempool->buckets[BUCKET_SLOT], ALLOC_SIZE);
410
- }
411
- else if (mempool->large.head != NULL)
412
- {
413
- new_mem = __FindMemNode(&mempool->large, ALLOC_SIZE);
414
- }
415
-
416
- if (new_mem == NULL)
417
- {
418
- // not enough memory to support the size!
419
- if ((mempool->arena.offs - ALLOC_SIZE) < mempool->arena.mem) return NULL;
420
- else
421
- {
422
- // Couldn't allocate from a freelist, allocate from available mempool.
423
- // Subtract allocation size from the mempool.
424
- mempool->arena.offs -= ALLOC_SIZE;
425
-
426
- // Use the available mempool space as the new node.
427
- new_mem = ( MemNode* )mempool->arena.offs;
428
- new_mem->size = ALLOC_SIZE;
429
- }
430
- }
431
-
432
- // Visual of the allocation block.
433
- // --------------
434
- // | mem size | lowest addr of block
435
- // | next node | 12 byte (32-bit) header
436
- // | prev node | 24 byte (64-bit) header
437
- // |------------|
438
- // | alloc'd |
439
- // | memory |
440
- // | space | highest addr of block
441
- // --------------
442
- new_mem->next = new_mem->prev = NULL;
443
- uint8_t *const restrict final_mem = ( uint8_t* )new_mem + sizeof *new_mem;
444
- return memset(final_mem, 0, new_mem->size - sizeof *new_mem);
445
- }
446
- }
447
-
448
- void *MemPoolRealloc(MemPool *const restrict mempool, void *const ptr, const size_t size)
449
- {
450
- if (size > mempool->arena.size) return NULL;
451
- // NULL ptr should make this work like regular Allocation.
452
- else if (ptr == NULL) return MemPoolAlloc(mempool, size);
453
- else if ((uintptr_t)ptr - sizeof(MemNode) < mempool->arena.mem) return NULL;
454
- else
455
- {
456
- MemNode *const node = ( MemNode* )(( uint8_t* )ptr - sizeof *node);
457
- const size_t NODE_SIZE = sizeof *node;
458
- uint8_t *const resized_block = MemPoolAlloc(mempool, size);
459
- if (resized_block == NULL) return NULL;
460
- else
461
- {
462
- MemNode *const resized = ( MemNode* )(resized_block - sizeof *resized);
463
- memmove(resized_block, ptr, (node->size > resized->size)? (resized->size - NODE_SIZE) : (node->size - NODE_SIZE));
464
- MemPoolFree(mempool, ptr);
465
- return resized_block;
466
- }
467
- }
468
- }
469
-
470
- void MemPoolFree(MemPool *const restrict mempool, void *const ptr)
471
- {
472
- const uintptr_t p = ( uintptr_t )ptr;
473
- if ((ptr == NULL) || (p - sizeof(MemNode) < mempool->arena.mem)) return;
474
- else
475
- {
476
- // Behind the actual pointer data is the allocation info.
477
- const uintptr_t block = p - sizeof(MemNode);
478
- MemNode *const mem_node = ( MemNode* )block;
479
- const size_t BUCKET_SLOT = (mem_node->size >> MEMPOOL_BUCKET_BITS) - 1;
480
-
481
- // Make sure the pointer data is valid.
482
- if ((block < mempool->arena.offs) ||
483
- ((block - mempool->arena.mem) > mempool->arena.size) ||
484
- (mem_node->size == 0) ||
485
- (mem_node->size > mempool->arena.size)) return;
486
- // If the mem_node is right at the arena offs, then merge it back to the arena.
487
- else if (block == mempool->arena.offs)
488
- {
489
- mempool->arena.offs += mem_node->size;
490
- }
491
- else
492
- {
493
- // try to place it into bucket or large freelist.
494
- struct AllocList *const l = (BUCKET_SLOT < MEMPOOL_BUCKET_SIZE) ? &mempool->buckets[BUCKET_SLOT] : &mempool->large;
495
- __InsertMemNode(mempool, l, mem_node, (BUCKET_SLOT < MEMPOOL_BUCKET_SIZE));
496
- }
497
- }
498
- }
499
-
500
- void MemPoolCleanUp(MemPool *const restrict mempool, void **const ptrref)
501
- {
502
- if ((ptrref == NULL) || (*ptrref == NULL)) return;
503
- else
504
- {
505
- MemPoolFree(mempool, *ptrref);
506
- *ptrref = NULL;
507
- }
508
- }
509
-
510
- size_t GetMemPoolFreeMemory(const MemPool mempool)
511
- {
512
- size_t total_remaining = mempool.arena.offs - mempool.arena.mem;
513
-
514
- for (MemNode *n=mempool.large.head; n != NULL; n = n->next) total_remaining += n->size;
515
-
516
- for (size_t i=0; i<MEMPOOL_BUCKET_SIZE; i++) for (MemNode *n = mempool.buckets[i].head; n != NULL; n = n->next) total_remaining += n->size;
517
-
518
- return total_remaining;
519
- }
520
-
521
- void MemPoolReset(MemPool *const mempool)
522
- {
523
- mempool->large.head = mempool->large.tail = NULL;
524
- mempool->large.len = 0;
525
- for (size_t i = 0; i < MEMPOOL_BUCKET_SIZE; i++)
526
- {
527
- mempool->buckets[i].head = mempool->buckets[i].tail = NULL;
528
- mempool->buckets[i].len = 0;
529
- }
530
- mempool->arena.offs = mempool->arena.mem + mempool->arena.size;
531
- }
532
-
533
- //----------------------------------------------------------------------------------
534
- // Module Functions Definition - Object Pool
535
- //----------------------------------------------------------------------------------
536
-
537
- ObjPool CreateObjPool(const size_t objsize, const size_t len)
538
- {
539
- ObjPool objpool = { 0 };
540
- if ((len == 0) || (objsize == 0)) return objpool;
541
- else
542
- {
543
- const size_t aligned_size = __AlignSize(objsize, sizeof(size_t));
544
- uint8_t *const restrict buf = calloc(len, aligned_size);
545
- if (buf == NULL) return objpool;
546
- objpool.objSize = aligned_size;
547
- objpool.memSize = objpool.freeBlocks = len;
548
- objpool.mem = ( uintptr_t )buf;
549
-
550
- for (size_t i=0; i<objpool.freeBlocks; i++)
551
- {
552
- size_t *const restrict index = ( size_t* )(objpool.mem + (i*aligned_size));
553
- *index = i + 1;
554
- }
555
-
556
- objpool.offs = objpool.mem;
557
- return objpool;
558
- }
559
- }
560
-
561
- ObjPool CreateObjPoolFromBuffer(void *const restrict buf, const size_t objsize, const size_t len)
562
- {
563
- ObjPool objpool = { 0 };
564
-
565
- // If the object size isn't large enough to align to a size_t, then we can't use it.
566
- const size_t aligned_size = __AlignSize(objsize, sizeof(size_t));
567
- if ((buf == NULL) || (len == 0) || (objsize < sizeof(size_t)) || (objsize*len != aligned_size*len)) return objpool;
568
- else
569
- {
570
- objpool.objSize = aligned_size;
571
- objpool.memSize = objpool.freeBlocks = len;
572
- objpool.mem = (uintptr_t)buf;
573
-
574
- for (size_t i=0; i<objpool.freeBlocks; i++)
575
- {
576
- size_t *const restrict index = ( size_t* )(objpool.mem + (i*aligned_size));
577
- *index = i + 1;
578
- }
579
-
580
- objpool.offs = objpool.mem;
581
- return objpool;
582
- }
583
- }
584
-
585
- void DestroyObjPool(ObjPool *const restrict objpool)
586
- {
587
- if (objpool->mem == 0) return;
588
- else
589
- {
590
- void *const restrict ptr = ( void* )objpool->mem;
591
- free(ptr);
592
- *objpool = (ObjPool){0};
593
- }
594
- }
595
-
596
- void *ObjPoolAlloc(ObjPool *const objpool)
597
- {
598
- if (objpool->freeBlocks > 0)
599
- {
600
- // For first allocation, head points to the very first index.
601
- // Head = &pool[0];
602
- // ret = Head == ret = &pool[0];
603
- size_t *const restrict block = ( size_t* )objpool->offs;
604
- objpool->freeBlocks--;
605
-
606
- // after allocating, we set head to the address of the index that *Head holds.
607
- // Head = &pool[*Head * pool.objsize];
608
- objpool->offs = (objpool->freeBlocks != 0)? objpool->mem + (*block*objpool->objSize) : 0;
609
- return memset(block, 0, objpool->objSize);
610
- }
611
- else return NULL;
612
- }
613
-
614
- void ObjPoolFree(ObjPool *const restrict objpool, void *const ptr)
615
- {
616
- uintptr_t block = (uintptr_t)ptr;
617
- if ((ptr == NULL) || (block < objpool->mem) || (block > objpool->mem + objpool->memSize*objpool->objSize)) return;
618
- else
619
- {
620
- // When we free our pointer, we recycle the pointer space to store the previous index and then we push it as our new head.
621
- // *p = index of Head in relation to the buffer;
622
- // Head = p;
623
- size_t *const restrict index = ( size_t* )block;
624
- *index = (objpool->offs != 0)? (objpool->offs - objpool->mem)/objpool->objSize : objpool->memSize;
625
- objpool->offs = block;
626
- objpool->freeBlocks++;
627
- }
628
- }
629
-
630
- void ObjPoolCleanUp(ObjPool *const restrict objpool, void **const restrict ptrref)
631
- {
632
- if (ptrref == NULL) return;
633
- else
634
- {
635
- ObjPoolFree(objpool, *ptrref);
636
- *ptrref = NULL;
637
- }
638
- }
639
-
640
-
641
- //----------------------------------------------------------------------------------
642
- // Module Functions Definition - Double-Ended Stack
643
- //----------------------------------------------------------------------------------
644
- BiStack CreateBiStack(const size_t len)
645
- {
646
- BiStack destack = { 0 };
647
- if (len == 0) return destack;
648
-
649
- uint8_t *const buf = malloc(len*sizeof *buf);
650
- if (buf==NULL) return destack;
651
- destack.size = len;
652
- destack.mem = ( uintptr_t )buf;
653
- destack.front = destack.mem;
654
- destack.back = destack.mem + len;
655
- return destack;
656
- }
657
-
658
- BiStack CreateBiStackFromBuffer(void *const buf, const size_t len)
659
- {
660
- BiStack destack = { 0 };
661
- if (len == 0 || buf == NULL) return destack;
662
- else
663
- {
664
- destack.size = len;
665
- destack.mem = destack.front = ( uintptr_t )buf;
666
- destack.back = destack.mem + len;
667
- return destack;
668
- }
669
- }
670
-
671
- void DestroyBiStack(BiStack *const restrict destack)
672
- {
673
- if (destack->mem == 0) return;
674
- else
675
- {
676
- uint8_t *const restrict buf = ( uint8_t* )destack->mem;
677
- free(buf);
678
- *destack = (BiStack){0};
679
- }
680
- }
681
-
682
- void *BiStackAllocFront(BiStack *const restrict destack, const size_t len)
683
- {
684
- if (destack->mem == 0) return NULL;
685
- else
686
- {
687
- const size_t ALIGNED_LEN = __AlignSize(len, sizeof(uintptr_t));
688
- // front end arena is too high!
689
- if (destack->front + ALIGNED_LEN >= destack->back) return NULL;
690
- else
691
- {
692
- uint8_t *const restrict ptr = ( uint8_t* )destack->front;
693
- destack->front += ALIGNED_LEN;
694
- return ptr;
695
- }
696
- }
697
- }
698
-
699
- void *BiStackAllocBack(BiStack *const restrict destack, const size_t len)
700
- {
701
- if (destack->mem == 0) return NULL;
702
- else
703
- {
704
- const size_t ALIGNED_LEN = __AlignSize(len, sizeof(uintptr_t));
705
- // back end arena is too low
706
- if (destack->back - ALIGNED_LEN <= destack->front) return NULL;
707
- else
708
- {
709
- destack->back -= ALIGNED_LEN;
710
- uint8_t *const restrict ptr = ( uint8_t* )destack->back;
711
- return ptr;
712
- }
713
- }
714
- }
715
-
716
- void BiStackResetFront(BiStack *const destack)
717
- {
718
- if (destack->mem == 0) return;
719
- else destack->front = destack->mem;
720
- }
721
-
722
- void BiStackResetBack(BiStack *const destack)
723
- {
724
- if (destack->mem == 0) return;
725
- else destack->back = destack->mem + destack->size;
726
- }
727
-
728
- void BiStackResetAll(BiStack *const destack)
729
- {
730
- BiStackResetBack(destack);
731
- BiStackResetFront(destack);
732
- }
733
-
734
- inline intptr_t BiStackMargins(const BiStack destack)
735
- {
736
- return destack.back - destack.front;
737
- }
738
-
739
- #endif // RMEM_IMPLEMENTATION
740
-
741
- /*******
742
- * Changelog
743
- * v1.0: First Creation.
744
- * v1.1: bug patches for the mempool and addition of object pool.
745
- * v1.2: addition of bidirectional arena.
746
- * v1.3:
747
- * optimizations of allocators.
748
- * renamed 'Stack' to 'Arena'.
749
- * replaced certain define constants with an anonymous enum.
750
- * refactored MemPool to no longer require active or deferred defragging.
751
- ********/