1717#ifndef _FIELD_H_
1818#define _FIELD_H_
1919
20- #include " gridstore.h"
2120#include < iostream>
2221#include < string.h>
2322
23+ #include " gridstore.h"
24+
2425using namespace std ;
2526
2627namespace griddb {
@@ -33,32 +34,24 @@ struct Field {
3334 };
3435
3536 ~Field () {
36- switch (type){
37+ switch (type) {
3738 case GS_TYPE_STRING:
3839 if (value.asString ) {
3940 free (const_cast <GSChar*>(value.asString ));
40- value.asString = NULL ;
4141 }
4242 break ;
4343 case GS_TYPE_BLOB:
4444 if (value.asBlob .data ) {
4545 free (const_cast <void *>(value.asBlob .data ));
46- value.asBlob .data = NULL ;
4746 }
4847 break ;
49- case GS_TYPE_INTEGER_ARRAY:
5048#if GS_COMPATIBILITY_VALUE_1_1_106
49+ case GS_TYPE_INTEGER_ARRAY:
5150 if (value.asIntegerArray .elements ) {
5251 free (const_cast <int32_t *> (value.asIntegerArray .elements ));
5352 }
54- #else
55- if (value.asArray .elements .asInteger ) {
56- free (const_cast <int32_t *> (value.asArray .elements .asInteger ));
57- }
58- #endif
5953 break ;
6054 case GS_TYPE_STRING_ARRAY:
61- #if GS_COMPATIBILITY_VALUE_1_1_106
6255 if (value.asStringArray .elements ) {
6356 for (int j = 0 ; j < value.asStringArray .size ; j++) {
6457 if (value.asStringArray .elements [j]) {
@@ -67,7 +60,49 @@ struct Field {
6760 }
6861 free (const_cast <GSChar**> (value.asStringArray .elements ));
6962 }
63+ break ;
64+ case GS_TYPE_BOOL_ARRAY:
65+ if (value.asBoolArray .elements ) {
66+ free (const_cast <GSBool*> (value.asBoolArray .elements ));
67+ }
68+ break ;
69+ case GS_TYPE_BYTE_ARRAY:
70+ if (value.asByteArray .elements ) {
71+ free (const_cast <int8_t *> (value.asByteArray .elements ));
72+ }
73+ break ;
74+ case GS_TYPE_SHORT_ARRAY:
75+ if (value.asShortArray .elements ) {
76+ free (const_cast <int16_t *> (value.asShortArray .elements ));
77+ }
78+ break ;
79+ case GS_TYPE_LONG_ARRAY:
80+ if (value.asLongArray .elements ) {
81+ free (const_cast <int64_t *> (value.asLongArray .elements ));
82+ }
83+ break ;
84+ case GS_TYPE_FLOAT_ARRAY:
85+ if (value.asFloatArray .elements ) {
86+ free (const_cast <float *> (value.asFloatArray .elements ));
87+ }
88+ break ;
89+ case GS_TYPE_DOUBLE_ARRAY:
90+ if (value.asDoubleArray .elements ) {
91+ free (const_cast <double *> (value.asDoubleArray .elements ));
92+ }
93+ break ;
94+ case GS_TYPE_TIMESTAMP_ARRAY:
95+ if (value.asTimestampArray .elements ) {
96+ free (const_cast <GSTimestamp*> (value.asTimestampArray .elements ));
97+ }
98+ break ;
7099#else
100+ case GS_TYPE_INTEGER_ARRAY:
101+ if (value.asArray .elements .asInteger ) {
102+ free (const_cast <int32_t *> (value.asArray .elements .asInteger ));
103+ }
104+ break ;
105+ case GS_TYPE_STRING_ARRAY:
71106 if (value.asArray .elements .asString ) {
72107 for (int j = 0 ; j < value.asArray .length ; j++) {
73108 if (value.asArray .elements .asString [j]) {
@@ -76,86 +111,45 @@ struct Field {
76111 }
77112 free (const_cast <GSChar**> (value.asArray .elements .asString ));
78113 }
79- #endif
80114 break ;
81115 case GS_TYPE_BOOL_ARRAY:
82- #if GS_COMPATIBILITY_VALUE_1_1_106
83- if (value.asBoolArray .elements ) {
84- free (const_cast <GSBool*> (value.asBoolArray .elements ));
85- }
86- #else
87116 if (value.asArray .elements .asBool ) {
88117 free (const_cast <GSBool*> (value.asArray .elements .asBool ));
89118 }
90- #endif
91119 break ;
92120 case GS_TYPE_BYTE_ARRAY:
93- #if GS_COMPATIBILITY_VALUE_1_1_106
94- if (value.asByteArray .elements ) {
95- free (const_cast <int8_t *> (value.asByteArray .elements ));
96- value.asByteArray .elements = NULL ;
97- }
98- #else
99121 if (value.asArray .elements .asByte ) {
100122 free (const_cast <int8_t *> (value.asArray .elements .asByte ));
101- value.asArray .elements .asByte = NULL ;
102123 }
103- #endif
104124 break ;
105125 case GS_TYPE_SHORT_ARRAY:
106- #if GS_COMPATIBILITY_VALUE_1_1_106
107- if (value.asShortArray .elements ) {
108- free (const_cast <int16_t *> (value.asShortArray .elements ));
109- }
110- #else
111126 if (value.asArray .elements .asShort ) {
112127 free (const_cast <int16_t *> (value.asArray .elements .asShort ));
113128 }
114- #endif
115129 break ;
116130 case GS_TYPE_LONG_ARRAY:
117- #if GS_COMPATIBILITY_VALUE_1_1_106
118- if (value.asLongArray .elements ) {
119- free (const_cast <int64_t *> (value.asLongArray .elements ));
120- }
121- #else
122131 if (value.asArray .elements .asLong ) {
123132 free (const_cast <int64_t *> (value.asArray .elements .asLong ));
124133 }
125- #endif
126134 break ;
127135 case GS_TYPE_FLOAT_ARRAY:
128- #if GS_COMPATIBILITY_VALUE_1_1_106
129- if (value.asFloatArray .elements ) {
130- free (const_cast <float *> (value.asFloatArray .elements ));
131- }
132- #else
133136 if (value.asArray .elements .asFloat ) {
134137 free (const_cast <float *> (value.asArray .elements .asFloat ));
135138 }
136- #endif
137139 break ;
138140 case GS_TYPE_DOUBLE_ARRAY:
139- #if GS_COMPATIBILITY_VALUE_1_1_106
140- if (value.asDoubleArray .elements ) {
141- free (const_cast <double *> (value.asDoubleArray .elements ));
142- }
143- #else
144141 if (value.asArray .elements .asDouble ) {
145142 free (const_cast <double *> (value.asArray .elements .asDouble ));
146143 }
147- #endif
148144 break ;
149145 case GS_TYPE_TIMESTAMP_ARRAY:
150- #if GS_COMPATIBILITY_VALUE_1_1_106
151- if (value.asTimestampArray .elements ) {
152- free (const_cast <GSTimestamp*> (value.asTimestampArray .elements ));
153- }
154- #else
155146 if (value.asArray .elements .asTimestamp ) {
156147 free (const_cast <GSTimestamp*> (value.asArray .elements .asTimestamp ));
157148 }
149+ break ;
158150#endif
151+ default :
152+ // not need to free allocation
159153 break ;
160154 }
161155 }
0 commit comments