mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-30 23:03:05 +00:00 
			
		
		
		
	Pointer safety, code cleaning
This commit is contained in:
		| @@ -18,7 +18,7 @@ | ||||
|  */ | ||||
|  | ||||
| #include "volk_gnsssdr/volk_gnsssdr_malloc.h" | ||||
| #include <pthread.h> | ||||
| #include <stdlib.h> | ||||
| #include <stdio.h> | ||||
| #include <string.h> | ||||
|  | ||||
| @@ -27,29 +27,6 @@ | ||||
|  * see: http://linux.die.net/man/3/aligned_alloc | ||||
|  */ | ||||
|  | ||||
| // Disabling use of aligned_alloc. This function requires that size be | ||||
| // a multiple of alignment, which is too restrictive for many uses of | ||||
| // VOLK. | ||||
|  | ||||
| //// If we are using C11 standard, use the aligned_alloc | ||||
| //#ifdef _ISOC11_SOURCE | ||||
| // | ||||
| //void *volk_gnsssdr_malloc(size_t size, size_t alignment) | ||||
| //{ | ||||
| //  void *ptr = aligned_alloc(alignment, size); | ||||
| //  if(ptr == NULL) { | ||||
| //    fprintf(stderr, "VOLK: Error allocating memory (aligned_alloc)\n"); | ||||
| //  } | ||||
| //  return ptr; | ||||
| //} | ||||
| // | ||||
| //void volk_gnsssdr_free(void *ptr) | ||||
| //{ | ||||
| //  free(ptr); | ||||
| //} | ||||
| // | ||||
| //#else // _ISOC11_SOURCE | ||||
|  | ||||
| // Otherwise, test if we are a POSIX or X/Open system | ||||
| // This only has a restriction that alignment be a power of 2and a | ||||
| // multiple of sizeof(void *). | ||||
|   | ||||
| @@ -21,19 +21,17 @@ | ||||
| #include <string.h> | ||||
| #include <volk_gnsssdr/volk_gnsssdr_prefs.h> | ||||
|  | ||||
| //#if defined(_WIN32) | ||||
| //#include <Windows.h> | ||||
| //#endif | ||||
|  | ||||
| void volk_gnsssdr_get_config_path(char *path) | ||||
| { | ||||
|     if (!path) return; | ||||
|     const char *suffix = "/.volk_gnsssdr/volk_gnsssdr_config"; | ||||
|     char *home = NULL; | ||||
|     if (home == NULL) home = getenv("HOME"); | ||||
|     if (home == NULL) home = getenv("APPDATA"); | ||||
|     if (home == NULL) | ||||
|         { | ||||
|             path = NULL; | ||||
|             path[0] = 0; | ||||
|             return; | ||||
|         } | ||||
|     strcpy(path, home); | ||||
| @@ -49,7 +47,7 @@ size_t volk_gnsssdr_load_preferences(volk_gnsssdr_arch_pref_t **prefs_res) | ||||
|  | ||||
|     //get the config path | ||||
|     volk_gnsssdr_get_config_path(path); | ||||
|     if (path == NULL) return n_arch_prefs; //no prefs found | ||||
|     if (!path[0]) return n_arch_prefs; //no prefs found | ||||
|     config_file = fopen(path, "r"); | ||||
|     if(!config_file) return n_arch_prefs; //no prefs found | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Carles Fernandez
					Carles Fernandez