1 /*
2 Copyright (c) 1998--2006 Benhur Stein
3
4 This file is part of Paj�.
5
6 Paj� is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2 of the License, or (at your
9 option) any later version.
10
11 Paj� is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14 for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with Paj�; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
19 */
20
21
22 //////////////////////////////////////////////////
23 /* Author: Geovani Ricardo Wiedenhoft */
24 /* Email: grw@inf.ufsm.br */
25 //////////////////////////////////////////////////
26
27
28
29 #include "JRastro.h"
30
hash_copy_string_data(hash_element_t * element,hash_key_t key,hash_data_t data)31 void hash_copy_string_data (hash_element_t *element, hash_key_t key, hash_data_t data)
32 {
33 hash_null(element);
34 hash_null(key);
35 hash_null(data);
36
37 element->key = (void *) malloc(sizeof(char) * (strlen((char *)key) + 1));
38 element->key = memcpy(element->key, key, sizeof(char) * (strlen((char *)key) + 1));
39
40 element->data = (void *) malloc(sizeof(jvmtiClassDefinition));
41 element->data = memcpy(element->data, data, sizeof(jvmtiClassDefinition));
42
43 }
44
hash_destroy_string_data(hash_element_t * element)45 void hash_destroy_string_data(hash_element_t *element)
46 {
47 hash_null(element);
48
49 free(element->key);
50 element->key=NULL;
51
52 free(element->data);
53 element->data=NULL;
54 }
55
hash_destroy_string_list(hash_element_t * element)56 void hash_destroy_string_list(hash_element_t *element)
57 {
58 hash_null(element);
59
60 free(element->key);
61 element->key=NULL;
62
63 list_t *tmp = (list_t *)element->data;
64 list_finalize(tmp);
65 free(element->data);
66 element->data=NULL;
67 }
68
hash_destroy_new(hash_element_t * element)69 void hash_destroy_new(hash_element_t *element)
70 {
71 hash_null(element);
72
73 element->key = NULL;
74 element->data = NULL;
75 }
76
hash_copy_new(hash_element_t * element,hash_key_t key,hash_data_t data)77 void hash_copy_new(hash_element_t *element, hash_key_t key, hash_data_t data)
78 {
79 hash_null(element);
80 hash_null(key);
81 hash_null(data);
82
83 element->key = (void *)key;
84
85 element->data = (void *)data;
86 }
87
hash_destroy_new_thread(hash_element_t * element)88 void hash_destroy_new_thread(hash_element_t *element)
89 {
90 hash_null(element);
91
92 element->key = NULL;
93
94 free(element->data);
95 element->data = NULL;
96 }
97
98