mirror of
				https://github.com/simon987/wavelib.git
				synced 2025-10-25 13:46:53 +00:00 
			
		
		
		
	Zero-sized array added again
pragma added for MSVC compiler.
This commit is contained in:
		
							parent
							
								
									ebcc2f9860
								
							
						
					
					
						commit
						5e5fe8ffa8
					
				| @ -3,6 +3,10 @@ | |||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
| #include "wavelib.h" | #include "wavelib.h" | ||||||
|  | #if defined(_MSC_VER) | ||||||
|  | #pragma warning(disable : 4200) | ||||||
|  | #pragma warning(disable : 4996) | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
| wave_object wave_init(char* wname) { | wave_object wave_init(char* wname) { | ||||||
| 	wave_object obj = NULL; | 	wave_object obj = NULL; | ||||||
| @ -15,8 +19,7 @@ wave_object wave_init(char* wname) { | |||||||
| 		//strcopy(obj->wname, wname);
 | 		//strcopy(obj->wname, wname);
 | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	obj = (wave_object)malloc(sizeof(struct wave_set)); |     obj = (wave_object)malloc(sizeof(struct wave_set) + sizeof(double) * 4 * retval); | ||||||
|     obj->params = (double*)malloc(sizeof(double) * 4 * retval); |  | ||||||
| 
 | 
 | ||||||
| 	obj->filtlength = retval; | 	obj->filtlength = retval; | ||||||
| 	obj->lpd_len = obj->hpd_len = obj->lpr_len = obj->hpr_len = obj->filtlength; | 	obj->lpd_len = obj->hpd_len = obj->lpr_len = obj->hpr_len = obj->filtlength; | ||||||
| @ -50,14 +53,12 @@ wt_object wt_init(wave_object wave,char* method, int siglength,int J) { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if (method == NULL) { | 	if (method == NULL) { | ||||||
| 		obj = (wt_object)malloc(sizeof(struct wt_set)); |         obj = (wt_object)malloc(sizeof(struct wt_set) + sizeof(double)* (siglength + 2 * J * (size + 1))); | ||||||
|         obj->params = (double*)malloc(sizeof(double)* (siglength + 2 * J * (size + 1))); |  | ||||||
| 		obj->outlength = siglength + 2 * J * (size + 1); // Default
 | 		obj->outlength = siglength + 2 * J * (size + 1); // Default
 | ||||||
| 		strcpy(obj->ext, "sym"); // Default
 | 		strcpy(obj->ext, "sym"); // Default
 | ||||||
| 	} | 	} | ||||||
| 	else if (!strcmp(method, "dwt") || !strcmp(method, "DWT")) { | 	else if (!strcmp(method, "dwt") || !strcmp(method, "DWT")) { | ||||||
| 		obj = (wt_object)malloc(sizeof(struct wt_set)); |         obj = (wt_object)malloc(sizeof(struct wt_set) + sizeof(double)* (siglength + 2 * J * (size + 1))); | ||||||
|         obj->params = (double*)malloc(sizeof(double)* (siglength + 2 * J * (size + 1))); |  | ||||||
| 		obj->outlength = siglength + 2 * J * (size + 1); // Default
 | 		obj->outlength = siglength + 2 * J * (size + 1); // Default
 | ||||||
| 		strcpy(obj->ext, "sym"); // Default
 | 		strcpy(obj->ext, "sym"); // Default
 | ||||||
| 	} | 	} | ||||||
| @ -67,8 +68,7 @@ wt_object wt_init(wave_object wave,char* method, int siglength,int J) { | |||||||
| 			exit(-1); | 			exit(-1); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		obj = (wt_object)malloc(sizeof(struct wt_set)); |         obj = (wt_object)malloc(sizeof(struct wt_set) + sizeof(double)* (siglength * (J + 1))); | ||||||
|         obj->params = (double*)malloc(sizeof(double)* (siglength * (J + 1))); |  | ||||||
| 		obj->outlength = siglength * (J + 1); // Default
 | 		obj->outlength = siglength * (J + 1); // Default
 | ||||||
| 		strcpy(obj->ext, "per"); // Default
 | 		strcpy(obj->ext, "per"); // Default
 | ||||||
| 	} | 	} | ||||||
| @ -83,8 +83,7 @@ wt_object wt_init(wave_object wave,char* method, int siglength,int J) { | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		obj = (wt_object)malloc(sizeof(struct wt_set)); |         obj = (wt_object)malloc(sizeof(struct wt_set) + sizeof(double)* (siglength * (J + 1))); | ||||||
|         obj->params = (double*)malloc(sizeof(double)* (siglength * (J + 1))); |  | ||||||
| 		obj->outlength = siglength * (J + 1); // Default
 | 		obj->outlength = siglength * (J + 1); // Default
 | ||||||
| 		strcpy(obj->ext, "per"); // Default
 | 		strcpy(obj->ext, "per"); // Default
 | ||||||
| 	} | 	} | ||||||
| @ -150,8 +149,7 @@ wtree_object wtree_init(wave_object wave, int siglength,int J) { | |||||||
| 	  elength += temp2; | 	  elength += temp2; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	obj = (wtree_object)malloc(sizeof(struct wtree_set)); |     obj = (wtree_object)malloc(sizeof(struct wtree_set) + sizeof(double)* (siglength * (J + 1) + elength + nodes + J + 1)); | ||||||
|     obj->params = (double*)malloc(sizeof(double)* (siglength * (J + 1) + elength + nodes + J + 1)); |  | ||||||
| 	obj->outlength = siglength * (J + 1) + elength; | 	obj->outlength = siglength * (J + 1) + elength; | ||||||
| 	strcpy(obj->ext, "sym"); | 	strcpy(obj->ext, "sym"); | ||||||
| 
 | 
 | ||||||
| @ -224,8 +222,7 @@ wpt_object wpt_init(wave_object wave, int siglength, int J) { | |||||||
| 	} | 	} | ||||||
| 	//printf("elength %d", elength);
 | 	//printf("elength %d", elength);
 | ||||||
| 
 | 
 | ||||||
| 	obj = (wpt_object)malloc(sizeof(struct wpt_set)); |     obj = (wpt_object)malloc(sizeof(struct wpt_set) + sizeof(double)* (elength + 4 * nodes + 2 * J + 6)); | ||||||
|     obj->params = (double*)malloc(sizeof(double)* (elength + 4 * nodes + 2 * J + 6)); |  | ||||||
| 	obj->outlength = siglength + 2 * (J + 1) * (size + 1); | 	obj->outlength = siglength + 2 * (J + 1) * (size + 1); | ||||||
| 	strcpy(obj->ext, "sym"); | 	strcpy(obj->ext, "sym"); | ||||||
| 	strcpy(obj->entropy, "shannon"); | 	strcpy(obj->entropy, "shannon"); | ||||||
| @ -2537,21 +2534,17 @@ void wpt_summary(wpt_object wt) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void wave_free(wave_object object) { | void wave_free(wave_object object) { | ||||||
|     free(object->params); |  | ||||||
| 	free(object); | 	free(object); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void wt_free(wt_object object) { | void wt_free(wt_object object) { | ||||||
|     free(object->params); |  | ||||||
| 	free(object); | 	free(object); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void wtree_free(wtree_object object) { | void wtree_free(wtree_object object) { | ||||||
|     free(object->params); |  | ||||||
| 	free(object); | 	free(object); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void wpt_free(wpt_object object) { | void wpt_free(wpt_object object) { | ||||||
|     free(object->params); |  | ||||||
| 	free(object); | 	free(object); | ||||||
| } | } | ||||||
|  | |||||||
| @ -25,7 +25,7 @@ struct wave_set{ | |||||||
| 	double *hpd; | 	double *hpd; | ||||||
| 	double *lpr; | 	double *lpr; | ||||||
| 	double *hpr; | 	double *hpr; | ||||||
| 	double *params; |     double params[0]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| typedef struct wt_set* wt_object; | typedef struct wt_set* wt_object; | ||||||
| @ -50,7 +50,7 @@ struct wt_set{ | |||||||
| 	int zpad; | 	int zpad; | ||||||
| 	int length[102]; | 	int length[102]; | ||||||
| 	double *output; | 	double *output; | ||||||
| 	double *params; |     double params[0]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| typedef struct wtree_set* wtree_object; | typedef struct wtree_set* wtree_object; | ||||||
| @ -77,7 +77,7 @@ struct wtree_set{ | |||||||
| 	double *output; | 	double *output; | ||||||
| 	int *nodelength; | 	int *nodelength; | ||||||
| 	int *coeflength; | 	int *coeflength; | ||||||
| 	double *params; |     double params[0]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| typedef struct wpt_set* wpt_object; | typedef struct wpt_set* wpt_object; | ||||||
| @ -106,7 +106,7 @@ struct wpt_set{ | |||||||
| 	int *nodeindex; | 	int *nodeindex; | ||||||
| 	int *numnodeslevel; | 	int *numnodeslevel; | ||||||
| 	int *coeflength; | 	int *coeflength; | ||||||
| 	double *params; |     double params[0]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user