File: nifti_tester002.c

package info (click to toggle)
nifticlib 3.0.1-9.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,640 kB
  • sloc: ansic: 31,214; sh: 941; makefile: 460; csh: 138; python: 88; tcl: 42
file content (38 lines) | stat: -rw-r--r-- 993 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * nifti_test2 -- this exercises a particular bug, whereby nifti_copy_nim_info was
 * not working correctly, which left the copy of an image pointing to the same
 * extension list, which could cause all sorts of grief.
 */
#include <nifti1_io.h>
int main (int argc, char *argv[])
{
  if (argc > 1)
  {
    printf("The test program takes no arguments: %s", argv[0]);
    return EXIT_FAILURE;
  }

  /*
   * create a 'dummy' image
   */
  nifti_image *i1 = nifti_simple_init_nim();
  nifti_image *i2;

  /*
   * add an extension to the dummy
   */
  static char ext[] = "THIS IS A TEST";
  nifti_add_extension(i1,ext,sizeof(ext),NIFTI_ECODE_COMMENT);
  /*
   * make a new nim from the dummy
   */
  i2 = nifti_copy_nim_info(i1);
  /*
   * if the bug isn't fixed in niftilib, the second nifti_image_free
   * will fail because both nims point to the same extensions. With gcc
   * this will abort inside the standard library
   */
  nifti_image_free(i1);
  nifti_image_free(i2);
  return 0;
}