Skip to content

Commit e032d2a

Browse files
steve-sansalond
authored andcommitted
Implement S_realloc
(cherry picked from commit 5efb59c)
1 parent 980659a commit e032d2a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ New features:
55
* the default `Renviron` file sets `R_LIBS_USER` to a directory inside the current user's home
66
* running the `configure_fastr` will change this to a path that also contains GraalVM version and will create the directory
77

8+
Added missing C APIs:
9+
10+
* `S_realloc`
11+
812
Bug fixes:
913

1014
* fatal error on Linux when pressing CTRL+C during long computation
@@ -23,7 +27,7 @@ Bug fixes:
2327
* new Truffle interop converts `double` values to `int` values if they fit in the integer range
2428
* see the changes in the [spec tests](https://github.com/oracle/fastr/commit/e08e2b19571479dddb6167d9a1d492a14cb4c7b2#diff-c842fa11097793b19bd410589c36af99)
2529

26-
Added missing R builtins and C APIa
30+
Added missing R builtins and C APIs
2731

2832
* simple support for the weak reference API functions (`R_MakeWeakRef`, `R_MakeWeakRefC`, `R_WeakRefKey`, `R_WeakRefValue`)
2933
* `Rf_i1mach`

com.oracle.truffle.r.native/fficall/src/truffle_nfi/Memory.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright (c) 1995-2015, The R Core Team
33
* Copyright (c) 2003, The R Foundation
4-
* Copyright (c) 2015, 2018, Oracle and/or its affiliates
4+
* Copyright (c) 2015, 2019, Oracle and/or its affiliates
55
*
66
* This program is free software; you can redistribute it and/or modify
77
* it under the terms of the GNU General Public License as published by
@@ -37,8 +37,11 @@ char *S_alloc(long n, int size) {
3737
return p;
3838
}
3939

40-
char *S_realloc(char *p, long a, long b, int size) {
41-
return unimplemented("S_realloc");
40+
char *S_realloc(char *p, long new_size, long old_size, int elt_size) {
41+
char* res = R_alloc(new_size, elt_size);
42+
long min_size = new_size < old_size ? new_size : old_size;
43+
memcpy(res, p, min_size * elt_size);
44+
return res;
4245
}
4346

4447
void *R_chk_calloc(size_t nelem, size_t elsize) {

0 commit comments

Comments
 (0)