Jon Medhurst | aaf37a3 | 2013-06-11 12:10:56 +0100 | [diff] [blame^] | 1 | /* |
| 2 | general.h - Part of libsensors, a Linux library for reading sensor data. |
| 3 | Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with this program; if not, write to the Free Software |
| 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
| 18 | MA 02110-1301 USA. |
| 19 | */ |
| 20 | |
| 21 | #ifndef LIB_SENSORS_GENERAL |
| 22 | #define LIB_SENSORS_GENERAL |
| 23 | |
| 24 | /* These are general purpose functions. They allow you to use variable- |
| 25 | length arrays, which are extended automatically. A distinction is |
| 26 | made between the current number of elements and the maximum number. |
| 27 | You can only add elements at the end. Primitive, but very useful |
| 28 | for internal use. */ |
| 29 | void sensors_malloc_array(void *list, int *num_el, int *max_el, |
| 30 | int el_size); |
| 31 | void sensors_free_array(void *list, int *num_el, int *max_el); |
| 32 | void sensors_add_array_el(const void *el, void *list, int *num_el, |
| 33 | int *max_el, int el_size); |
| 34 | void sensors_add_array_els(const void *els, int nr_els, void *list, |
| 35 | int *num_el, int *max_el, int el_size); |
| 36 | |
| 37 | #define ARRAY_SIZE(arr) (int)(sizeof(arr) / sizeof((arr)[0])) |
| 38 | |
| 39 | #endif /* LIB_SENSORS_GENERAL */ |