The R Project SVN R

Rev

Rev 13365 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13365 Rev 26207
Line 1... Line 1...
1
/*
1
/*
2
 *  BDX: Binary Data eXchange format library
2
 *  BDX: Binary Data eXchange format library
3
 *  Copyright (C) 1999--2001 Thomas Baier
3
 *  Copyright (C) 1999--2001 Thomas Baier
4
 * 
4
 *
5
 *  This library is free software; you can redistribute it and/or
5
 *  This library is free software; you can redistribute it and/or
6
 *  modify it under the terms of the GNU Library General Public
6
 *  modify it under the terms of the GNU Library General Public
7
 *  License as published by the Free Software Foundation; either
7
 *  License as published by the Free Software Foundation; either
8
 *  version 2 of the License, or (at your option) any later version.
8
 *  version 2 of the License, or (at your option) any later version.
9
 * 
9
 *
10
 *  This library is distributed in the hope that it will be useful,
10
 *  This library is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 *  Library General Public License for more details.
13
 *  Library General Public License for more details.
14
 * 
14
 *
15
 *  You should have received a copy of the GNU Library General Public
15
 *  You should have received a copy of the GNU Library General Public
16
 *  License along with this library; if not, write to the Free
16
 *  License along with this library; if not, write to the Free
17
 *  Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
17
 *  Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18
 *  MA 02111-1307, USA
18
 *  MA 02111-1307, USA
19
 *
19
 *
20
 *  $Id: bdx.c,v 1.5 2001/04/05 09:42:35 ripley Exp $
20
 *  $Id: bdx.c,v 1.6 2003/09/13 15:14:09 murdoch Exp $
21
 */
21
 */
22
 
22
 
23
#include <stdlib.h>
23
#include <stdlib.h>
24
#include <assert.h>
24
#include <assert.h>
25
#include "bdx.h"
25
#include "bdx.h"
Line 29... Line 29...
29
  if (data == NULL)
29
  if (data == NULL)
30
    {
30
    {
31
      return;
31
      return;
32
    }
32
    }
33
 
33
 
34
  // even for scalars, the dimensions are correctly initialized (just a 1
34
  /* even for scalars, the dimensions are correctly initialized (just a 1 */
35
  // dimension structure with just one element)
35
  /* dimension structure with just one element) */
36
  assert (data != NULL);
36
  assert (data != NULL);
37
  assert (data->dimensions != NULL);
37
  assert (data->dimensions != NULL);
38
  assert (data->raw_data != NULL);
38
  assert (data->raw_data != NULL);
39
 
39
 
40
  // is it a character array/vector/scalar? if yes, release the data
40
  /* is it a character array/vector/scalar? if yes, release the data */
41
  if ((data->type & BDX_SMASK) == BDX_STRING)
41
  if ((data->type & BDX_SMASK) == BDX_STRING)
42
    {
42
    {
43
      // treat the data as a 1-dimensional array with |dim1|*|dim2|*...
43
      /* treat the data as a 1-dimensional array with |dim1|*|dim2|*... */
44
      // elements
44
      /* elements */
45
      int total_size = 1;
45
      int total_size = 1;
46
      int i;
46
      int i;
47
 
47
 
48
      for (i = 0;i < data->dim_count;i++)
48
      for (i = 0;i < data->dim_count;i++)
49
	{
49
	{
Line 57... Line 57...
57
	      free (data->raw_data[i].string_value);
57
	      free (data->raw_data[i].string_value);
58
	    }
58
	    }
59
	}
59
	}
60
    }
60
    }
61
 
61
 
62
  // free data pointers, dimension data and the data block itself
62
  /* free data pointers, dimension data and the data block itself */
63
  free (data->raw_data);
63
  free (data->raw_data);
64
  free (data->dimensions);
64
  free (data->dimensions);
65
  free (data);
65
  free (data);
66
}
66
}