LIBHPCS_API struct HPCS_MethodInfo* LIBHPCS_CC hpcs_alloc_minfo();
LIBHPCS_API void LIBHPCS_CC hpcs_free_mdata(struct HPCS_MeasuredData* const mdata);
LIBHPCS_API void LIBHPCS_CC hpcs_free_minfo(struct HPCS_MethodInfo* const minfo);
-LIBHPCS_API char* LIBHPCS_CC hpcs_error_to_string(const enum HPCS_RetCode);
+LIBHPCS_API const char* LIBHPCS_CC hpcs_error_to_string(const enum HPCS_RetCode);
LIBHPCS_API enum HPCS_RetCode LIBHPCS_CC hpcs_read_mdata(const char* filename, struct HPCS_MeasuredData* mdata);
LIBHPCS_API enum HPCS_RetCode LIBHPCS_CC hpcs_read_minfo(const char* filename, struct HPCS_MethodInfo* minfo);
return minfo;
}
-char* hpcs_error_to_string(const enum HPCS_RetCode err)
+const char* hpcs_error_to_string(const enum HPCS_RetCode err)
{
- char* msg;
-
switch (err) {
case HPCS_OK:
- msg = malloc(strlen(HPCS_OK_STR) + 1);
- strcpy(msg, HPCS_OK_STR);
- return msg;
+ return HPCS_OK_STR;
case HPCS_E_NULLPTR:
- msg = malloc(strlen(HPCS_E_NULLPTR_STR) + 1);
- strcpy(msg, HPCS_E_NULLPTR_STR);
- return msg;
+ return HPCS_E_NULLPTR_STR;
case HPCS_E_CANT_OPEN:
- msg = malloc(strlen(HPCS_E_CANT_OPEN_STR) + 1);
- strcpy(msg, HPCS_E_CANT_OPEN_STR);
- return msg;
+ return HPCS_E_CANT_OPEN_STR;
case HPCS_E_PARSE_ERROR:
- msg = malloc(strlen(HPCS_E_PARSE_ERROR_STR) + 1);
- strcpy(msg, HPCS_E_PARSE_ERROR_STR);
- return msg;
+ return HPCS_E_PARSE_ERROR_STR;
case HPCS_E_UNKNOWN_TYPE:
- msg = malloc(strlen(HPCS_E_UNKNOWN_TYPE_STR) + 1);
- strcpy(msg, HPCS_E_UNKNOWN_TYPE_STR);
- return msg;
+ return HPCS_E_UNKNOWN_TYPE_STR;
default:
- msg = malloc(strlen(HPCS_E__UNKNOWN_EC_STR) + 1);
- strcpy(msg, HPCS_E__UNKNOWN_EC_STR);
- return msg;
+ return HPCS_E__UNKNOWN_EC_STR;
}
}
char* value = NULL;
pret = parse_native_method_info_line(&name, &value, line);
- if (pret != PARSE_OK)
+ if (pret != PARSE_OK) {
+ free(name);
+ free(value);
return pret;
+ }
if (minfo->count+1 > allocated) {
size_t to_allocate;
w_name = wcstok(line, EQUALITY_SIGN);
if (w_name == NULL)
return PARSE_E_NOT_FOUND;
+
+ ret = __win32_wchar_to_utf8(name, w_name);
+ if (ret != PARSE_OK)
+ return ret;
+
w_value = wcstok(NULL, EQUALITY_SIGN);
if (w_value == NULL) {
/* Add an empty string if there is no value */
*value[0] = 0;
return PARSE_OK;
}
-
/* Remove trailing \n from w_value, if any */
w_newline = StrStrW(w_value, CR_LF);
if (w_newline != NULL)
*w_newline = (WCHAR)0;
- ret = __win32_wchar_to_utf8(name, w_name);
- if (ret != PARSE_OK)
- return ret;
ret = __win32_wchar_to_utf8(value, w_value);
if (ret != PARSE_OK)
return ret;
u_name = u_strtok_r(line, EQUALITY_SIGN, &saveptr);
if (u_name == NULL)
return PARSE_E_NOT_FOUND;
+ ret = __unix_icu_to_utf8(name, u_name);
+ if (ret != PARSE_OK)
+ return ret;
+
u_value = u_strtok_r(NULL, EQUALITY_SIGN, &saveptr);
if (u_value == NULL) {
/* Add an empty string if there is no value */
if (newline != NULL)
*newline = (UChar)0;
- ret = __unix_icu_to_utf8(name, u_name);
- if (ret != PARSE_OK)
- return ret;
ret = __unix_icu_to_utf8(value, u_value);
if (ret != PARSE_OK)
return ret;