File: hdiff_mattbl.c

package info (click to toggle)
libhdf4 4.2.10-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 25,488 kB
  • ctags: 12,954
  • sloc: ansic: 146,962; sh: 14,905; fortran: 12,480; makefile: 922; yacc: 680; pascal: 418; lex: 170; csh: 41
file content (127 lines) | stat: -rw-r--r-- 3,728 bytes parent folder | download
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF.  The full HDF copyright notice, including       *
 * terms governing use, modification, and redistribution, is contained in    *
 * the files COPYING and Copyright.html.  COPYING can be found at the root   *
 * of the source code distribution tree; Copyright.html can be found at      *
 * http://hdfgroup.org/products/hdf4/doc/Copyright.html.  If you do not have *
 * access to either file, you may request a copy from help@hdfgroup.org.     *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */


#include <stdio.h>
#include <stdlib.h>

#include "hdiff_mattbl.h"


/*-------------------------------------------------------------------------
 * Function: match_table_add
 *
 * Purpose: mark object is in file;
 *  flag[0] = file1
 *  flag[1] = file2
 *  object exists in file = flag = 1
 *  does not exist        = flag = 0
 * the key is <path, tag, ref >
 *
 * Return: void
 *
 * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
 *
 * Date: August 25, 2003
 *
 *-------------------------------------------------------------------------
 */

void match_table_add (match_table_t *table, 
                      unsigned *flags, 
                      char* path, 
                      int32 tag1, 
                      int32 ref1,
                      int32 tag2, 
                      int32 ref2 )
{
    uint32 i;
    
    if (table->nobjs == table->size) {
        table->size *= 2;
        table->objs = (match_info_t*)realloc(table->objs, table->size * sizeof(match_info_t));
        
        for (i = table->nobjs; i < table->size; i++) {
            table->objs[i].tag1 = table->objs[i].ref1 = -1;
            table->objs[i].tag2 = table->objs[i].ref2 = -1;
            table->objs[i].flags[0] = table->objs[i].flags[1] = -1;
        }
    }
    
    i = table->nobjs++;
    table->objs[i].tag1 = tag1;
    table->objs[i].ref1 = ref1;
    table->objs[i].tag2 = tag2;
    table->objs[i].ref2 = ref2;
    strcpy(table->objs[i].obj_name,path);
    table->objs[i].flags[0] = flags[0];
    table->objs[i].flags[1] = flags[1];
}


/*-------------------------------------------------------------------------
 * Function: match_table_init
 *
 * Purpose: initialize table
 *
 * Return: void
 *
 * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
 *
 * Date: July 3, 2003
 *
 *-------------------------------------------------------------------------
 */

void match_table_init( match_table_t **tbl )
{
    uint32 i;
    match_table_t* table = (match_table_t*) malloc(sizeof(match_table_t));
    
    table->size = 20;
    table->nobjs = 0;
    table->objs = (match_info_t*) malloc(table->size * sizeof(match_info_t));
    
    for (i = 0; i < table->size; i++) {
        table->objs[i].tag1 = table->objs[i].ref1 = -1;
        table->objs[i].tag2 = table->objs[i].ref2 = -1;
        table->objs[i].flags[0] = table->objs[i].flags[1] = -1;
    }
    
    *tbl = table;
}



/*-------------------------------------------------------------------------
 * Function: match_table_free
 *
 * Purpose: free table memory
 *
 * Return: void
 *
 * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
 *
 * Date: July 3, 2003
 *
 *-------------------------------------------------------------------------
 */

void match_table_free( match_table_t *table )
{
    free(table->objs);
    free(table);
}