replace strdup with const str

This commit is contained in:
estkme 2024-01-09 19:46:09 +08:00
parent 2dd4a00d69
commit 8dcc3cda31
4 changed files with 19 additions and 23 deletions

View file

@ -580,16 +580,16 @@ int es10b_list_notification(struct euicc_ctx *ctx, struct es10b_notification_met
switch (asn1metadata->profileManagementOperation.buf[0])
{
case 128:
metadata->profileManagementOperation = strdup("install");
metadata->profileManagementOperation = "install";
break;
case 64:
metadata->profileManagementOperation = strdup("enable");
metadata->profileManagementOperation = "enable";
break;
case 32:
metadata->profileManagementOperation = strdup("disable");
metadata->profileManagementOperation = "disable";
break;
case 16:
metadata->profileManagementOperation = strdup("delete");
metadata->profileManagementOperation = "delete";
break;
}
@ -965,7 +965,6 @@ void es10b_notification_metadata_free_all(struct es10b_notification_metadata *me
}
for (int i = 0; i < count; i++)
{
free(metadatas[i].profileManagementOperation);
free(metadatas[i].notificationAddress);
free(metadatas[i].iccid);
}

View file

@ -14,7 +14,7 @@ struct es10b_prepare_download_param
struct es10b_notification_metadata
{
unsigned long seqNumber;
char *profileManagementOperation;
const char *profileManagementOperation;
char *notificationAddress;
char *iccid;
};

View file

@ -111,13 +111,13 @@ int es10c_get_profiles_info(struct euicc_ctx *ctx, struct es10c_profile_info **p
switch (profileState)
{
case ES10C_PROFILE_INFO_STATE_DISABLED:
p->profileState = strdup("disabled");
p->profileState = "disabled";
break;
case ES10C_PROFILE_INFO_STATE_ENABLED:
p->profileState = strdup("enabled");
p->profileState = "enabled";
break;
default:
p->profileState = strdup("unknown");
p->profileState = "unknown";
break;
}
}
@ -131,16 +131,16 @@ int es10c_get_profiles_info(struct euicc_ctx *ctx, struct es10c_profile_info **p
switch (profileClass)
{
case ES10C_PROFILE_INFO_CLASS_TEST:
p->profileClass = strdup("test");
p->profileClass = "test";
break;
case ES10C_PROFILE_INFO_CLASS_PROVISIONING:
p->profileClass = strdup("provisioning");
p->profileClass = "provisioning";
break;
case ES10C_PROFILE_INFO_CLASS_OPERATIONAL:
p->profileClass = strdup("operational");
p->profileClass = "operational";
break;
default:
p->profileClass = strdup("unknown");
p->profileClass = "unknown";
break;
}
}
@ -184,19 +184,19 @@ int es10c_get_profiles_info(struct euicc_ctx *ctx, struct es10c_profile_info **p
switch (iconType)
{
case ES10C_ICON_TYPE_JPEG:
p->iconType = strdup("jpeg");
p->iconType = "jpeg";
break;
case ES10C_ICON_TYPE_PNG:
p->iconType = strdup("png");
p->iconType = "png";
break;
default:
p->iconType = strdup("unknown");
p->iconType = "unknown";
break;
}
}
else
{
p->iconType = strdup("none");
p->iconType = "none";
}
if (asn1p->icon)
@ -923,12 +923,9 @@ void es10c_profile_info_free_all(struct es10c_profile_info *profiles, int count)
}
for (int i = 0; i < count; i++)
{
free(profiles[i].profileState);
free(profiles[i].profileClass);
free(profiles[i].profileNickname);
free(profiles[i].serviceProviderName);
free(profiles[i].profileName);
free(profiles[i].iconType);
free(profiles[i].icon);
}
free(profiles);

View file

@ -26,12 +26,12 @@ struct es10c_profile_info
{
char iccid[(10 * 2) + 1];
char isdpAid[(16 * 2) + 1];
char *profileState;
char *profileClass;
const char *profileState;
const char *profileClass;
char *profileNickname;
char *serviceProviderName;
char *profileName;
char *iconType;
const char *iconType;
char *icon;
};