1 /* src/client/misc.c */
4 #include <stddef.h> /* size_t */
5 #include <stdint.h> /* uint8_t, uint32_t */
6 #include <stdlib.h> /* free() */
7 #include <string.h> /* memcpy() */
8 #include "../common/try_malloc.h" /* try_malloc() */
9 #include "world.h" /* global world */
13 extern void nav_inventory(char dir)
17 world.player_inventory_select = world.player_inventory_select
18 - (world.player_inventory_select > 0);
23 for (i = 0; '\0' != world.player_inventory[i]; i++)
25 n_elems = n_elems + ('\n' == world.player_inventory[i]);
27 world.player_inventory_select = world.player_inventory_select
28 + (world.player_inventory_select < n_elems);
33 extern void array_append(uint32_t old_n, size_t region_size, void * new_region,
34 void ** ptr_old_array)
36 char * f_name = "array_append()";
37 uint32_t old_size = old_n * region_size;
38 uint32_t new_size = old_size + region_size;
39 char * new_array = try_malloc(new_size, f_name);
40 memcpy(new_array, * ptr_old_array, old_size);
41 memcpy(new_array + (old_n * region_size), new_region, region_size);
42 free(* ptr_old_array);
43 * ptr_old_array = new_array;