Skip to content

Commit

Permalink
Fix Issue #108: warning -> Rf_warning in C++
Browse files Browse the repository at this point in the history
  • Loading branch information
kbroman committed Aug 16, 2024
1 parent 96d3bd2 commit 4fb4f24
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: qtl
Version: 1.67-2
Date: 2024-08-15
Version: 1.67-3
Date: 2024-08-16
Title: Tools for Analyzing QTL Experiments
Author: Karl W Broman <[email protected]> and Hao Wu, with
ideas from Gary Churchill and Saunak Sen and contributions from
Expand Down
5 changes: 4 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Revision history for the R/qtl package

## Version 1.67-2, 2024-08-14
## Version 1.67-3, 2024-08-16

### Minor changes

Expand All @@ -9,6 +9,9 @@
- Small change to C code in simulate.c for R-devel: change calls to
Calloc, Realloc, and Free to R_Calloc, R_Realloc, and R_Free.

- In mqmdatatypes.cpp, changed calls to warning() to calls to Rf_warning()
to avoid compile error in R-devel.


## Version 1.66, 2023-11-27

Expand Down
20 changes: 10 additions & 10 deletions src/mqmdatatypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* mqmdatatypes.cpp
*
* Copyright (c) 1996-2009 by
* Copyright (c) 1996-2024 by
* Ritsert C Jansen, Danny Arends, Pjotr Prins and Karl W Broman
*
* initial MQM C code written between 1996-2002 by Ritsert C. Jansen
Expand Down Expand Up @@ -95,7 +95,7 @@ void change_coding(int *Nmark, int *Nind, int **Geno, MQMMarkerMatrix markers, c
case 9: markers[j][i] = MMISSING;
break;
default:
error("Can not convert R/qtl genotype with value %d",Geno[j][i]);
Rf_error("Can not convert R/qtl genotype with value %d",Geno[j][i]);
}
}
}
Expand All @@ -114,37 +114,37 @@ void *calloc_init(size_t num, size_t size) {

vector newvector(int dim) {
vector v = (double *)calloc_init(dim, sizeof(double));
if(!v){ warning("Not enough memory for new vector of dimension %d", (dim+1)); }
if(!v){ Rf_warning("Not enough memory for new vector of dimension %d", (dim+1)); }
return v;
}

ivector newivector(int dim) {
ivector v = (int *)calloc_init(dim, sizeof(int));
if(!v){ warning("Not enough memory for new vector of dimension %d", (dim+1)); }
if(!v){ Rf_warning("Not enough memory for new vector of dimension %d", (dim+1)); }
return v;
}

cvector newcvector(int dim) {
cvector v = (char *)calloc_init(dim, sizeof(char));
if(!v){ warning("Not enough memory for new vector of dimension %d", (dim+1)); }
if(!v){ Rf_warning("Not enough memory for new vector of dimension %d", (dim+1)); }
return v;
}

MQMMarkerVector newMQMMarkerVector(int dim) {
MQMMarkerVector v = (MQMMarker *)calloc_init(dim, sizeof(MQMMarker));
if(!v){ warning("Not enough memory for new mqm marker vector of dimension %d", (dim+1)); }
if(!v){ Rf_warning("Not enough memory for new mqm marker vector of dimension %d", (dim+1)); }
return v;
}

relmarkerarray newRelMarkerPos(int dim){
relmarkerarray v = (MQMRelMarkerPos *)calloc_init(dim, sizeof(char));
if(!v){ warning("Not enough memory for the relative marker position vector with dimension %d",(dim+1)); }
if(!v){ Rf_warning("Not enough memory for the relative marker position vector with dimension %d",(dim+1)); }
return v;
}

matrix newmatrix(int rows, int cols) {
matrix m = (double **)calloc_init(rows, sizeof(double*));
if(!m){ warning("Not enough memory for new double matrix"); }
if(!m){ Rf_warning("Not enough memory for new double matrix"); }
for (int i=0; i<rows; i++) {
m[i]= newvector(cols);
}
Expand All @@ -171,7 +171,7 @@ void printcmatrix(cmatrix m, int rows, int cols) {

cmatrix newcmatrix(int rows, int cols) {
cmatrix m = (char **)calloc_init(rows, sizeof(char*));
if(!m){ warning("Not enough memory for new char matrix"); }
if(!m){ Rf_warning("Not enough memory for new char matrix"); }
for (int i=0; i<rows; i++) {
m[i]= newcvector(cols);
}
Expand All @@ -181,7 +181,7 @@ cmatrix newcmatrix(int rows, int cols) {

MQMMarkerMatrix newMQMMarkerMatrix(int rows, int cols) {
MQMMarkerMatrix m = (MQMMarkerMatrix)calloc_init(rows, sizeof(MQMMarkerVector));
if(!m){ warning("Not enough memory for new markermatrix"); }
if(!m){ Rf_warning("Not enough memory for new markermatrix"); }
for (int i=0; i<rows; i++) {
m[i]= newMQMMarkerVector(cols);
}
Expand Down

0 comments on commit 4fb4f24

Please sign in to comment.