The R Project SVN R

Rev

Rev 26894 | Rev 36820 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 26894 Rev 27319
Line 1... Line 1...
1
/*
1
/*
2
 *  Mathlib : A C Library of Special Functions
2
 *  Mathlib : A C Library of Special Functions
3
 *  Copyright (C) 1999-2001  The R Development Core Team
3
 *  Copyright (C) 1999-2003  The R Development Core Team
4
 *
4
 *
5
 *  This program is free software; you can redistribute it and/or modify
5
 *  This program is free software; you can redistribute it and/or modify
6
 *  it under the terms of the GNU General Public License as published by
6
 *  it under the terms of the GNU General Public License as published by
7
 *  the Free Software Foundation; either version 2 of the License, or
7
 *  the Free Software Foundation; either version 2 of the License, or
8
 *  (at your option) any later version.
8
 *  (at your option) any later version.
Line 48... Line 48...
48
static void
48
static void
49
w_free(int n)
49
w_free(int n)
50
{
50
{
51
    int i;
51
    int i;
52
 
52
 
53
    if(!w) return;
53
    if (!w) return;
54
    n = imax2(n, SIGNRANK_MAX);
54
    n = imax2(n, SIGNRANK_MAX);
55
    for (i = n; i >= 0; i--)
55
    for (i = n; i >= 0; i--)
56
	if(w[i]) {free((void *) w[i]); w[i] = 0;}
56
	if (w[i]) free((void *) w[i]);
57
    free((void *) w);
57
    free((void *) w);
58
    w = 0;
58
    w = 0;
59
    allocated_n = 0;
59
    allocated_n = 0;
60
}
60
}
61
 
61
 
Line 65... Line 65...
65
}
65
}
66
 
66
 
67
static void
67
static void
68
w_init_maybe(int n)
68
w_init_maybe(int n)
69
{
69
{
70
    if (w && (n > SIGNRANK_MAX))
70
    if (w && (n > allocated_n))
71
	w_free(SIGNRANK_MAX);
71
	w_free(allocated_n);
72
 
72
 
73
    if (!w) {
73
    if (!w) {
74
	allocated_n = n = imax2(n, SIGNRANK_MAX);
74
	allocated_n = n = imax2(n, SIGNRANK_MAX);
75
	w = (double **) calloc(n + 1, sizeof(double *));
75
	w = (double **) calloc(n + 1, sizeof(double *));
76
	if (!w)
76
	if (!w)