[R-pkg-team] Bug#1103199: [PATCH] Fix for FTBFS with R 4.5.0
liwenjun
liwenjun at kylinos.cn
Wed Apr 16 08:26:36 BST 2025
Package: src:r-bioc-oligo
Version: 1.70.0+ds-2
Severity: serious
Tags: ftbfs trixie sid
Dear maintainer:
Hi, I'm summitting a patch for fixing this FTBFS problem while building with R 4.5.0 on Debian sid,trixie.
My patch Fix-FTBFS-error.patch replace Calloc(),Realloc(),Free() to R_Calloc(),R_Realloc(),R_Free(), accoding to the R-project's NEWS(R: R News <https://cran.r-project.org/doc/manuals/r-release/NEWS.html>)
And by the way, Please help me for uploading this patch to upstream if you think it's necessary.
Best regards,
liwenjun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/r-pkg-team/attachments/20250416/ad5619bf/attachment-0001.htm>
-------------- next part --------------
Description: Fix FTBFS error on R 4.5.0
This patch replace Calloc(),Realloc() and Free() to R_Calloc(), R_Realloc() and R_Free()
for fixing FTBFS errors on DEBIAN sid, trixy.
Accoding to the R-project's NEWS.(https://cran.r-project.org/doc/manuals/r-release/NEWS.html).
R 4.5.0 has been changed those funtions.
Author: liwenjun <liwenjun at kylinos.cn>
Origin: other, None
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1103199
Last-Update: 2025-04-16
--- r-bioc-oligo-1.70.0+ds.orig/src/ParserGzXYS.c
+++ r-bioc-oligo-1.70.0+ds/src/ParserGzXYS.c
@@ -59,7 +59,7 @@ static char *gzxys_header_field(const ch
error("Can't find \'%s\' field. %s corrupted?", field, currentFile);
result = strtok(result, "=");
result = strtok(NULL, "\t");
- final = Calloc(strlen(result)+1, char);
+ final = R_Calloc(strlen(result)+1, char);
strcpy(final, result);
return final;
}
@@ -144,15 +144,15 @@ SEXP R_read_gzxys_files(SEXP filenames,
for (i = 1; i < nfiles; i++){
d1 = gzxys_header_field(CHAR(STRING_ELT(filenames, i)), "designname=");
if(strcasecmp(d1, d0) != 0){
- Free(d0);
- Free(d1);
+ R_Free(d0);
+ R_Free(d1);
error("\'%s\' and \'%s\' use different designs.\n",
CHAR(STRING_ELT(filenames, 0)),
CHAR(STRING_ELT(filenames, i)));
}
- Free(d1); // Missed: 12/02/09
+ R_Free(d1); // Missed: 12/02/09
}
- Free(d0);
+ R_Free(d0);
if (verbose) Rprintf("Done.\n");
// Allocating memory in R
@@ -170,7 +170,7 @@ SEXP R_read_gzxys_files(SEXP filenames,
ptr2xy, i, nrows, verbose);
d0 = gzxys_header_field(CHAR(STRING_ELT(filenames, i)), "date=");
SET_STRING_ELT(dates, i, mkChar(d0));
- Free(d0);
+ R_Free(d0);
}
PROTECT(output = allocVector(VECSXP, 3));
--- r-bioc-oligo-1.70.0+ds.orig/src/ParserXYS.c
+++ r-bioc-oligo-1.70.0+ds/src/ParserXYS.c
@@ -74,10 +74,10 @@ static void tokenizer(tokenset *header,
int i;
i = header->n;
header->n++;
- header->key = Realloc(header->key, header->n, char*);
- header->value = Realloc(header->value, header->n, char*);
- header->key[i] = Calloc(strlen(key)+1, char);
- header->value[i] = Calloc(strlen(value)+1, char);
+ header->key = R_Realloc(header->key, header->n, char*);
+ header->value = R_Realloc(header->value, header->n, char*);
+ header->key[i] = R_Calloc(strlen(key)+1, char);
+ header->value[i] = R_Calloc(strlen(value)+1, char);
strcpy(header->key[i], key);
strcpy(header->value[i], value);
}
@@ -90,12 +90,12 @@ static void tokenizer(tokenset *header,
static void untokenizer(tokenset *header){
int i;
for (i=0; i < header->n; i++){
- Free(header->key[i]);
- Free(header->value[i]);
+ R_Free(header->key[i]);
+ R_Free(header->value[i]);
}
- Free(header->key);
- Free(header->value);
- Free(header);
+ R_Free(header->key);
+ R_Free(header->value);
+ R_Free(header);
}
/***************************************************************
@@ -105,7 +105,7 @@ static void untokenizer(tokenset *header
***************************************************************/
static tokenset *buffer2tokenset(char *buffer){
- tokenset *header = Calloc(1, tokenset);
+ tokenset *header = R_Calloc(1, tokenset);
char *eq, *key, *value;
header->n = 0;
header->key = NULL;
@@ -157,7 +157,7 @@ static char *xys_header_field(const char
error("Can't find \'%s\' field. %s corrupted?", field, currentFile);
result = strtok(result, "=");
result = strtok(NULL, "\t");
- final = Calloc(strlen(result)+1, char);
+ final = R_Calloc(strlen(result)+1, char);
strcpy(final, result);
return final;
}
@@ -238,15 +238,15 @@ SEXP R_read_xys_files(SEXP filenames, SE
for (i = 1; i < nfiles; i++){
d1 = xys_header_field(CHAR(STRING_ELT(filenames, i)), "designname=");
if(strcasecmp(d1, d0) != 0){
- Free(d0);
- Free(d1);
+ R_Free(d0);
+ R_Free(d1);
error("\'%s\' and \'%s\' use different designs.\n",
CHAR(STRING_ELT(filenames, 0)),
CHAR(STRING_ELT(filenames, i)));
}
- Free(d1); // Missed: 12/02/09
+ R_Free(d1); // Missed: 12/02/09
}
- Free(d0);
+ R_Free(d0);
if (verbose) Rprintf("Done.\n");
// Allocating memory in R
@@ -264,7 +264,7 @@ SEXP R_read_xys_files(SEXP filenames, SE
ptr2xy, i, nrows, verbose);
d0 = xys_header_field(CHAR(STRING_ELT(filenames, i)), "date=");
SET_STRING_ELT(dates, i, mkChar(d0));
- Free(d0);
+ R_Free(d0);
}
PROTECT(output = allocVector(VECSXP, 3));
--- r-bioc-oligo-1.70.0+ds.orig/src/chipbackground.c
+++ r-bioc-oligo-1.70.0+ds/src/chipbackground.c
@@ -64,8 +64,8 @@
void static get_centroids(int rows, int cols, int grid_dim_rows, int grid_dim_cols, double *centroidx, double *centroidy){
int i,j;
- double *cuts_x = (double *)Calloc(grid_dim_rows,double);
- double *cuts_y = (double *)Calloc(grid_dim_cols,double);
+ double *cuts_x = (double *)R_Calloc(grid_dim_rows,double);
+ double *cuts_y = (double *)R_Calloc(grid_dim_cols,double);
for (i = 0; i < grid_dim_rows; i++)
cuts_x[i] = ((double)(i+1)*(double)rows)/(double)grid_dim_rows - (double)rows/(2.0*(double)grid_dim_rows);
@@ -78,8 +78,8 @@ void static get_centroids(int rows, int
centroidy[j*grid_dim_rows + i] = cuts_y[(j*grid_dim_rows + i) % grid_dim_rows]+0.5;
}
}
- Free(cuts_x);
- Free(cuts_y);
+ R_Free(cuts_x);
+ R_Free(cuts_y);
}
@@ -178,14 +178,14 @@ void static find_distances(int x, int y,
void static compute_weights_individual(int x, int y, int grid_dim, double *centroidx, double *centroidy, double *weights, double smooth){
int i=0;
- double *distance = (double *)Calloc(grid_dim,double);
+ double *distance = (double *)R_Calloc(grid_dim,double);
find_distances(x, y, grid_dim, centroidx, centroidy, distance);
for (i = 0; i < grid_dim; i++){
weights[i] = 1.0/((double)distance[i] + smooth);
}
- Free(distance);
+ R_Free(distance);
}
/*********************************************************************************************
@@ -348,9 +348,9 @@ void static compute_background_quadrant(
int lower2pc;
int i=0,j=0;
- int *nprobes_in_sec = (int *)Calloc(grid_dim,int);
- int *cur_n = (int *)Calloc(grid_dim,int);
- double **data_by_sector =(double **)Calloc(grid_dim,double *);
+ int *nprobes_in_sec = (int *)R_Calloc(grid_dim,int);
+ int *cur_n = (int *)R_Calloc(grid_dim,int);
+ double **data_by_sector =(double **)R_Calloc(grid_dim,double *);
double sumx,sumx2;
for (j = 0; j < grid_dim; j++){
@@ -362,7 +362,7 @@ void static compute_background_quadrant(
}
for (j =0; j < grid_dim; j++){
- data_by_sector[j] = (double *)Calloc(nprobes_in_sec[j],double);
+ data_by_sector[j] = (double *)R_Calloc(nprobes_in_sec[j],double);
}
for (j =0; j < grid_dim; j++){
@@ -406,12 +406,12 @@ void static compute_background_quadrant(
}
for (j =0; j < grid_dim; j++){
- Free(data_by_sector[j]);
+ R_Free(data_by_sector[j]);
}
- Free(nprobes_in_sec);
- Free(cur_n);
- Free(data_by_sector);
+ R_Free(nprobes_in_sec);
+ R_Free(cur_n);
+ R_Free(data_by_sector);
}
@@ -475,14 +475,14 @@ double static max(double one, double two
void static affy_background_adjust(double *probeintensity,int *x, int *y, int nprobes, int nchips, int rows, int cols, int grid_dim){
int i=0,j=0;
- int *whichgrid = (int *)Calloc(nprobes,int);
- double *bg_q = (double *)Calloc(grid_dim,double);
- double *noise_q = (double *)Calloc(grid_dim,double);
- double *weights = (double *)Calloc(grid_dim*nprobes,double);
- double *centroidx = (double *)Calloc(grid_dim,double);
- double *centroidy = (double *)Calloc(grid_dim,double);
- int *gridpt_x = (int *)Calloc(((int)(sqrt(grid_dim) -1.0)),int);
- int *gridpt_y = (int *)Calloc(((int)(sqrt(grid_dim) -1.0)),int);
+ int *whichgrid = (int *)R_Calloc(nprobes,int);
+ double *bg_q = (double *)R_Calloc(grid_dim,double);
+ double *noise_q = (double *)R_Calloc(grid_dim,double);
+ double *weights = (double *)R_Calloc(grid_dim*nprobes,double);
+ double *centroidx = (double *)R_Calloc(grid_dim,double);
+ double *centroidy = (double *)R_Calloc(grid_dim,double);
+ int *gridpt_x = (int *)R_Calloc(((int)(sqrt(grid_dim) -1.0)),int);
+ int *gridpt_y = (int *)R_Calloc(((int)(sqrt(grid_dim) -1.0)),int);
get_centroids(rows, cols, (int)sqrt(grid_dim),(int)sqrt(grid_dim), centroidx, centroidy);
get_gridpts(rows, cols, grid_dim, gridpt_x, gridpt_y);
@@ -499,14 +499,14 @@ void static affy_background_adjust(doubl
}
}
- Free(gridpt_x);
- Free(gridpt_y);
- Free(centroidx);
- Free(centroidy);
- Free(weights);
- Free(whichgrid);
- Free(noise_q);
- Free(bg_q);
+ R_Free(gridpt_x);
+ R_Free(gridpt_y);
+ R_Free(centroidx);
+ R_Free(centroidy);
+ R_Free(weights);
+ R_Free(whichgrid);
+ R_Free(noise_q);
+ R_Free(bg_q);
}
--- r-bioc-oligo-1.70.0+ds.orig/src/rma_common.c
+++ r-bioc-oligo-1.70.0+ds/src/rma_common.c
@@ -59,7 +59,7 @@ int sort_double(const double *a1,const d
double median(double *x, int length){
int half;
double med;
- double *buffer = Calloc(length,double);
+ double *buffer = R_Calloc(length,double);
memcpy(buffer,x,length*sizeof(double));
@@ -81,7 +81,7 @@ double median(double *x, int length){
med = (med + buffer[half])/2.0;
}
- Free(buffer);
+ R_Free(buffer);
return med;
}
@@ -101,7 +101,7 @@ double median(double *x, int length){
double median_nocopy(double *x, int length){
int half;
double med;
- double *buffer = x; //Calloc(length,double);
+ double *buffer = x; //R_Calloc(length,double);
memcpy(buffer,x,length*sizeof(double));
--- r-bioc-oligo-1.70.0+ds.orig/src/trimmed.c
+++ r-bioc-oligo-1.70.0+ds/src/trimmed.c
@@ -20,7 +20,7 @@ static void trimmed_mean(double *datavec
if (classvec[i] == class)
n++;
- double *buffer=Calloc(n, double);
+ double *buffer=R_Calloc(n, double);
for (i = 0; i < cols; i++)
if (classvec[i] == class){
buffer[j]=datavec[i];
@@ -41,13 +41,13 @@ static void trimmed_mean(double *datavec
m1[i_ext + (class-1) * rows]=sum;
m2[i_ext + (class-1) * rows]=sum2;
m3[i_ext + (class-1) * rows]=j;
- Free(buffer);
+ R_Free(buffer);
}
static void trimmed_stats(double *data, double *m1, double *m2, double *m3, int *class, int rows, int cols, double *trim){
int i, j, n1, n2, n3;
- double *datvec=Calloc(cols,double);
- int *classvec=Calloc(cols,int);
+ double *datvec=R_Calloc(cols,double);
+ int *classvec=R_Calloc(cols,int);
for (i=0; i < rows; i++){
n1=0;
@@ -76,8 +76,8 @@ static void trimmed_stats(double *data,
trimmed_mean(datvec, classvec, 2, trim[0], cols, rows, m1, m2, m3, i);
trimmed_mean(datvec, classvec, 3, trim[0], cols, rows, m1, m2, m3, i);
}
- Free(datvec);
- Free(classvec);
+ R_Free(datvec);
+ R_Free(classvec);
}
More information about the R-pkg-team
mailing list