The R Project SVN R

Rev

Rev 86521 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
65160 urbaneks 1
/*
2
 *  R : A Computer Language for Statistical Data Analysis
89942 luke 3
 *  Copyright (C) 2014-2026  The R Core Team
65160 urbaneks 4
 *
71657 plummer 5
 *  This header file is free software; you can redistribute it and/or modify
65160 urbaneks 6
 *  it under the terms of the GNU Lesser General Public License as published by
7
 *  the Free Software Foundation; either version 2.1 of the License, or
8
 *  (at your option) any later version.
9
 *
71657 plummer 10
 *  This file is part of R. R is distributed under the terms of the
11
 *  GNU General Public License, either Version 2, June 1991 or Version 3,
12
 *  June 2007. See doc/COPYRIGHTS for details of the copyright status of R.
13
 *
65160 urbaneks 14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU Lesser General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU Lesser General Public License
20
 *  along with this program; if not, a copy is available at
68949 ripley 21
 *  https://www.R-project.org/Licenses/
65160 urbaneks 22
 *
23
 *
24
 *  Definition of the R_allocator_t structure for custom allocators
25
 *  to be used with allocVector3()
86459 ripley 26
 *
86521 ripley 27
 *  allocVector3 is also not declared as API in
89942 luke 28
 *  Rinternals.h nor documented in R-exts.
65160 urbaneks 29
 */
30
 
31
#ifndef R_EXT_RALLOCATORS_H_
32
#define R_EXT_RALLOCATORS_H_
33
 
71371 ripley 34
#if defined(__cplusplus) && !defined(DO_NOT_USE_CXX_HEADERS)
35
# include <cstddef>
71289 ripley 36
#else
71371 ripley 37
# include <stddef.h> /* for size_t */
65160 urbaneks 38
#endif
39
 
40
/* R_allocator_t typedef is also declared in Rinternals.h 
41
   so we guard against random inclusion order */
42
#ifndef R_ALLOCATOR_TYPE
43
#define R_ALLOCATOR_TYPE
44
typedef struct R_allocator R_allocator_t;
45
#endif
46
 
47
typedef void *(*custom_alloc_t)(R_allocator_t *allocator, size_t);
48
typedef void  (*custom_free_t)(R_allocator_t *allocator, void *);
49
 
50
struct R_allocator {
51
    custom_alloc_t mem_alloc; /* malloc equivalent */
52
    custom_free_t  mem_free;  /* free equivalent */
53
    void *res;                /* reserved (maybe for copy) - must be NULL */
54
    void *data;               /* custom data for the allocator implementation */
55
};
56
 
57
#endif /* R_EXT_RALLOCATORS_H_ */