Skip to content

Commit

Permalink
update Calloc/Free to keep up with R-devel
Browse files Browse the repository at this point in the history
  • Loading branch information
kingaa committed Jan 16, 2022
1 parent 0d757ad commit ed18259
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 25 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: ouch
Type: Package
Title: Ornstein-Uhlenbeck Models for Phylogenetic Comparative Hypotheses
Version: 2.17-1
Date: 2021-08-20
Version: 2.17-2
Date: 2022-01-16
Authors@R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"),email="[email protected]"),
person(given=c("Marguerite","A."),family="Butler",role=c("ctb")))
Maintainer: Aaron A. King <[email protected]>
Expand All @@ -15,7 +15,7 @@ License: GPL-3
LazyLoad: true
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1.9000
RoxygenNote: 7.1.2
BugReports: https://github.com/kingaa/ouch/issues/
Encoding: UTF-8
Collate:
Expand Down
5 changes: 1 addition & 4 deletions man/package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ INSTALL = install
PKG = $(shell perl -ne 'print $$1 if /Package:\s+((\w+[-\.]?)+)/;' DESCRIPTION)
VERSION = $(shell perl -ne 'print $$1 if /Version:\s+((\d+[-\.]?)+)/;' DESCRIPTION)
PKGVERS = $(PKG)_$(VERSION)
SOURCE=$(wildcard R/*R src/*.c src/*.h data/*)
CSOURCE=$(wildcard src/*.c)
TESTS=$(wildcard tests/*R)
SOURCE=$(sort $(wildcard R/*R src/*.c src/*.h data/*))
CSOURCE=$(sort $(wildcard src/*.c))
TESTS=$(sort $(wildcard tests/*R))

default:
@echo $(PKGVERS)
Expand Down Expand Up @@ -69,7 +69,7 @@ session: install
revdeps: install
mkdir -p library check
$(REXE) -e "pkgs <- strsplit('$(REVDEPS)',' ')[[1]]; download.packages(pkgs,destdir='library',repos='https://mirrors.nics.utk.edu/cran/')"
$(RCMD) check --library=library -o check library/*.tar.gz
$(RCMD) check --as-cran --library=library -o check library/*.tar.gz

roxy: $(SOURCE) headers
$(REXE) -e "pkgbuild::compile_dll(); devtools::document(roclets=c('rd','collate','namespace'))"
Expand Down
16 changes: 8 additions & 8 deletions src/covar-matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ static void ouch_covar_matrix (int *nchar,
double tmp;
int n = *nchar, nt = *nterm;
int i, j, k, l, r, s;
U = Calloc(n*n,double);
W = Calloc(n*n,double);
elti = Calloc(n,double);
eltj = Calloc(n,double);
U = R_Calloc(n*n,double);
W = R_Calloc(n*n,double);
elti = R_Calloc(n,double);
eltj = R_Calloc(n,double);
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
U[i+j*n] = 0;
Expand Down Expand Up @@ -57,10 +57,10 @@ static void ouch_covar_matrix (int *nchar,
}
}
}
Free(U);
Free(W);
Free(elti);
Free(eltj);
R_Free(U);
R_Free(W);
R_Free(elti);
R_Free(eltj);
}

SEXP ouch_covar (SEXP object, SEXP lambda, SEXP S, SEXP sigmasq) {
Expand Down
12 changes: 6 additions & 6 deletions src/weight-matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ static void ouch_weight_matrix (int *nchar, int *neps, double *epochs, double *l
double t;
int n = *nchar, np = *neps;
int i, j, k, r;
elt = Calloc(np*n,double);
elt = R_Calloc(np*n,double);
for (i = 0; i < np; i++) {
t = epochs[0]-epochs[i];
for (j = 0; j < n; j++)
Expand All @@ -24,7 +24,7 @@ static void ouch_weight_matrix (int *nchar, int *neps, double *epochs, double *l
}
}
}
Free(elt);
R_Free(elt);
}

SEXP ouch_weights (SEXP object, SEXP lambda, SEXP S, SEXP beta) {
Expand All @@ -40,7 +40,7 @@ SEXP ouch_weights (SEXP object, SEXP lambda, SEXP S, SEXP beta) {
nt = INTEGER(nterm)[0];
SET_STRING_ELT(nm,0,mkChar("epochs"));
PROTECT(epochs = GET_SLOT(object,nm)); nprotect++;
nreg = Calloc(nchar,int);
nreg = R_Calloc(nchar,int);
totreg = 0;
for (i = 0; i < nchar; i++) {
nreg[i] = INTEGER(GET_DIM(VECTOR_ELT(VECTOR_ELT(beta,0),i)))[1];
Expand All @@ -50,7 +50,7 @@ SEXP ouch_weights (SEXP object, SEXP lambda, SEXP S, SEXP beta) {
PROTECT(W = makearray(2,xdim)); nprotect++;
for (i = 0; i < nt; i++) {
np = GET_LENGTH(VECTOR_ELT(epochs,i));
y = Calloc(nchar*nchar*np,double);
y = R_Calloc(nchar*nchar*np,double);
ouch_weight_matrix(&nchar,&np,REAL(VECTOR_ELT(epochs,i)),REAL(lambda),REAL(S),y);
for (n = 0, ptr = 0; n < nchar; ptr += nt*nchar*nreg[n++]) {
wp = &(REAL(W))[ptr];
Expand All @@ -64,9 +64,9 @@ SEXP ouch_weights (SEXP object, SEXP lambda, SEXP S, SEXP beta) {
}
}
}
Free(y);
R_Free(y);
}
Free(nreg);
R_Free(nreg);
UNPROTECT(nprotect);
return W;
}
Expand Down

0 comments on commit ed18259

Please sign in to comment.