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

View file

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

View file

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

View file

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