comparison src/share/native/sun/management/GcInfoBuilder.c @ 9359:343f4f8ba098

8029735: Enhance service mgmt natives Reviewed-by: sla, mschoene
author jbachorik
date Mon, 23 Dec 2013 15:33:11 +0100
parents 00cd9dc3c2b5
children b91cf8924877
comparison
equal deleted inserted replaced
1:361bce3a3539 2:a4ba86ca4a8d
57 if (gc == NULL) { 57 if (gc == NULL) {
58 JNU_ThrowNullPointerException(env, "Invalid GarbageCollectorMBean"); 58 JNU_ThrowNullPointerException(env, "Invalid GarbageCollectorMBean");
59 return; 59 return;
60 } 60 }
61 61
62 if (num_attributes == 0) { 62 if (num_attributes <= 0) {
63 JNU_ThrowIllegalArgumentException(env, "Invalid num_attributes"); 63 JNU_ThrowIllegalArgumentException(env, "Invalid num_attributes");
64 return; 64 return;
65 } 65 }
66 66
67 ext_att_info = (jmmExtAttributeInfo*) malloc(num_attributes * 67 ext_att_info = (jmmExtAttributeInfo*) malloc((size_t)num_attributes *
68 sizeof(jmmExtAttributeInfo)); 68 sizeof(jmmExtAttributeInfo));
69 if (ext_att_info == NULL) { 69 if (ext_att_info == NULL) {
70 JNU_ThrowOutOfMemoryError(env, 0); 70 JNU_ThrowOutOfMemoryError(env, 0);
71 return; 71 return;
72 } 72 }
76 JNU_ThrowInternalError(env, "Unexpected num_attributes"); 76 JNU_ThrowInternalError(env, "Unexpected num_attributes");
77 free(ext_att_info); 77 free(ext_att_info);
78 return; 78 return;
79 } 79 }
80 80
81 nativeTypes = (jchar*) malloc(num_attributes * sizeof(jchar)); 81 nativeTypes = (jchar*) malloc((size_t)num_attributes * sizeof(jchar));
82 if (nativeTypes == NULL) { 82 if (nativeTypes == NULL) {
83 free(ext_att_info); 83 free(ext_att_info);
84 JNU_ThrowOutOfMemoryError(env, 0); 84 JNU_ThrowOutOfMemoryError(env, 0);
85 return; 85 return;
86 } 86 }
186 if (gc == NULL) { 186 if (gc == NULL) {
187 JNU_ThrowNullPointerException(env, "Invalid GarbageCollectorMBean"); 187 JNU_ThrowNullPointerException(env, "Invalid GarbageCollectorMBean");
188 return 0; 188 return 0;
189 } 189 }
190 190
191 if (ext_att_count <= 0) {
192 JNU_ThrowIllegalArgumentException(env, "Invalid ext_att_count");
193 return;
194 }
195
191 gc_stat.usage_before_gc = usageBeforeGC; 196 gc_stat.usage_before_gc = usageBeforeGC;
192 gc_stat.usage_after_gc = usageAfterGC; 197 gc_stat.usage_after_gc = usageAfterGC;
193 gc_stat.gc_ext_attribute_values_size = ext_att_count; 198 gc_stat.gc_ext_attribute_values_size = ext_att_count;
194 if (ext_att_count > 0) { 199 if (ext_att_count > 0) {
195 gc_stat.gc_ext_attribute_values = (jvalue*) malloc(ext_att_count * 200 gc_stat.gc_ext_attribute_values = (jvalue*) malloc((size_t)ext_att_count *
196 sizeof(jvalue)); 201 sizeof(jvalue));
197 if (gc_stat.gc_ext_attribute_values == NULL) { 202 if (gc_stat.gc_ext_attribute_values == NULL) {
198 JNU_ThrowOutOfMemoryError(env, 0); 203 JNU_ThrowOutOfMemoryError(env, 0);
199 return 0; 204 return 0;
200 } 205 }
210 } 215 }
211 return 0; 216 return 0;
212 } 217 }
213 218
214 // convert the ext_att_types to native types 219 // convert the ext_att_types to native types
215 nativeTypes = (jchar*) malloc(ext_att_count * sizeof(jchar)); 220 nativeTypes = (jchar*) malloc((size_t)ext_att_count * sizeof(jchar));
216 if (nativeTypes == NULL) { 221 if (nativeTypes == NULL) {
217 if (gc_stat.gc_ext_attribute_values != NULL) { 222 if (gc_stat.gc_ext_attribute_values != NULL) {
218 free(gc_stat.gc_ext_attribute_values); 223 free(gc_stat.gc_ext_attribute_values);
219 } 224 }
220 JNU_ThrowOutOfMemoryError(env, 0); 225 JNU_ThrowOutOfMemoryError(env, 0);