RAPI
|
00001 /* 00002 * R : A Computer Language for Statistical Data Analysis 00003 * Copyright (C) 2014-2016 The R Core Team 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU Lesser General Public License as published by 00007 * the Free Software Foundation; either version 2.1 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public License 00016 * along with this program; if not, a copy is available at 00017 * https://www.R-project.org/Licenses/ 00018 * 00019 * 00020 * Definition of the R_allocator_t structure for custom allocators 00021 * to be used with allocVector3() 00022 */ 00023 00024 #ifndef R_EXT_RALLOCATORS_H_ 00025 #define R_EXT_RALLOCATORS_H_ 00026 00027 #ifndef NO_C_HEADERS 00028 # if defined(__cplusplus) && !defined(DO_NOT_USE_CXX_HEADERS) 00029 # include <cstddef> 00030 # else 00031 # include <stddef.h> /* for size_t */ 00032 # endif 00033 #endif 00034 00035 /* R_allocator_t typedef is also declared in Rinternals.h 00036 so we guard against random inclusion order */ 00037 #ifndef R_ALLOCATOR_TYPE 00038 #define R_ALLOCATOR_TYPE 00039 typedef struct R_allocator R_allocator_t; 00040 #endif 00041 00042 typedef void *(*custom_alloc_t)(R_allocator_t *allocator, size_t); 00043 typedef void (*custom_free_t)(R_allocator_t *allocator, void *); 00044 00045 struct R_allocator { 00046 custom_alloc_t mem_alloc; /* malloc equivalent */ 00047 custom_free_t mem_free; /* free equivalent */ 00048 void *res; /* reserved (maybe for copy) - must be NULL */ 00049 void *data; /* custom data for the allocator implementation */ 00050 }; 00051 00052 #endif /* R_EXT_RALLOCATORS_H_ */