diff --git a/camlibs/ptp2/chdk.c b/camlibs/ptp2/chdk.c index 4f3a182c4..96b207d05 100644 --- a/camlibs/ptp2/chdk.c +++ b/camlibs/ptp2/chdk.c @@ -117,19 +117,19 @@ chdk_generic_script_run ( case PTP_CHDK_TYPE_STRING: GP_LOG_D("string %s", msg->data); if (*table) { - *table = realloc(*table,strlen(*table)+strlen(msg->data)+1); + C_MEM (*table = realloc(*table,strlen(*table)+strlen(msg->data)+1)); strcat(*table,msg->data); } else { - *table = strdup(msg->data); + C_MEM (*table = strdup(msg->data)); } break; case PTP_CHDK_TYPE_TABLE: GP_LOG_D("table %s", msg->data); if (*table) { - *table = realloc(*table,strlen(*table)+strlen(msg->data)+1); + C_MEM (*table = realloc(*table,strlen(*table)+strlen(msg->data)+1)); strcat(*table,msg->data); } else { - *table = strdup(msg->data); + C_MEM (*table = strdup(msg->data)); } break; default: GP_LOG_E("unknown chdk msg->type %d", msg->subtype);break; @@ -178,7 +178,7 @@ chdk_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, char *xfolder; /* strip leading / of folders, except for the root folder */ - xfolder=strdup(folder); + C_MEM (xfolder=strdup(folder)); if (strlen(folder)>2 && (xfolder[strlen(xfolder)-1] == '/')) xfolder[strlen(xfolder)-1] = '\0'; @@ -250,7 +250,7 @@ chdk_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, name = t+strlen("name=."); s = strchr(name,'"'); if (s) *s='\0'; - name = strdup(name); + C_MEM (name = strdup(name)); GP_LOG_D("name is %s", name); *s = '"'; } diff --git a/camlibs/ptp2/config.c b/camlibs/ptp2/config.c index 2eeeab00c..30eda5be0 100644 --- a/camlibs/ptp2/config.c +++ b/camlibs/ptp2/config.c @@ -12298,7 +12298,7 @@ camera_lookup_by_property(Camera *camera, PTPDevicePropDesc *dpd, char **name, c continue; } CR (gp_widget_get_name (widget, (const char**)name)); - *name = strdup(*name?*name:""); + C_MEM (*name = strdup(*name?*name:"")); CR (gp_widget_get_type (widget, &type)); switch (type) { case GP_WIDGET_RADIO: @@ -12306,7 +12306,7 @@ camera_lookup_by_property(Camera *camera, PTPDevicePropDesc *dpd, char **name, c case GP_WIDGET_TEXT: { char *val; CR (gp_widget_get_value (widget, &val)); - *content = strdup(val?val:""); + C_MEM (*content = strdup(val?val:"")); break; } case GP_WIDGET_RANGE: { @@ -12314,11 +12314,11 @@ camera_lookup_by_property(Camera *camera, PTPDevicePropDesc *dpd, char **name, c float fval; CR (gp_widget_get_value (widget, &fval)); sprintf(buf,"%f",fval); - *content = strdup(buf); + C_MEM (*content = strdup(buf)); break; } default: - *content = strdup("Unhandled type"); + C_MEM (*content = strdup("Unhandled type")); /* FIXME: decode value ... ? date? toggle? */ break; } @@ -12338,7 +12338,7 @@ camera_lookup_by_property(Camera *camera, PTPDevicePropDesc *dpd, char **name, c continue; } CR (gp_widget_get_name (widget, (const char**)name)); - *name = strdup(*name); + C_MEM (*name = strdup(*name)); CR (gp_widget_get_type (widget, &type)); switch (type) { case GP_WIDGET_RADIO: @@ -12346,7 +12346,7 @@ camera_lookup_by_property(Camera *camera, PTPDevicePropDesc *dpd, char **name, c case GP_WIDGET_TEXT: { char *val; CR (gp_widget_get_value (widget, &val)); - *content = strdup(val); + C_MEM (*content = strdup(val)); break; } case GP_WIDGET_RANGE: { @@ -12354,11 +12354,11 @@ camera_lookup_by_property(Camera *camera, PTPDevicePropDesc *dpd, char **name, c float fval; CR (gp_widget_get_value (widget, &fval)); sprintf(buf,"%f",fval); - *content = strdup(buf); + C_MEM (*content = strdup(buf)); break; } default: - *content = strdup("Unhandled type"); + C_MEM (*content = strdup("Unhandled type")); /* FIXME: decode value ... ? date? toggle? */ break; } @@ -12376,7 +12376,7 @@ camera_lookup_by_property(Camera *camera, PTPDevicePropDesc *dpd, char **name, c continue; } CR (gp_widget_get_name (widget, (const char**)name)); - *name = strdup(*name); + C_MEM (*name = strdup(*name)); CR (gp_widget_get_type (widget, &type)); switch (type) { case GP_WIDGET_RADIO: @@ -12384,7 +12384,7 @@ camera_lookup_by_property(Camera *camera, PTPDevicePropDesc *dpd, char **name, c case GP_WIDGET_TEXT: { char *val; CR (gp_widget_get_value (widget, &val)); - *content = strdup(val?val:"NULL"); + C_MEM (*content = strdup(val?val:"NULL")); break; } case GP_WIDGET_RANGE: { @@ -12392,11 +12392,11 @@ camera_lookup_by_property(Camera *camera, PTPDevicePropDesc *dpd, char **name, c float fval; CR (gp_widget_get_value (widget, &fval)); sprintf(buf,"%f",fval); - *content = strdup(buf); + C_MEM (*content = strdup(buf)); break; } default: - *content = strdup("Unhandled type"); + C_MEM (*content = strdup("Unhandled type")); /* FIXME: decode value ... ? date? toggle? */ break; } @@ -12417,12 +12417,12 @@ camera_lookup_by_property(Camera *camera, PTPDevicePropDesc *dpd, char **name, c sprintf (buf, N_("PTP Property 0x%04x"), propid); label = buf; } - *name = strdup (label); + C_MEM (*name = strdup (label)); switch (dpd->DataType) { #define X(dtc,val,fmt) \ case dtc: \ sprintf (buf, fmt, dpd->CurrentValue.val); \ - *content = strdup (buf); \ + C_MEM (*content = strdup (buf)); \ return GP_OK; \ X(PTP_DTC_INT8,i8,"%d") @@ -12435,11 +12435,11 @@ camera_lookup_by_property(Camera *camera, PTPDevicePropDesc *dpd, char **name, c X(PTP_DTC_UINT64,u64,"%ld") #undef X case PTP_DTC_STR: - *content = strdup (dpd->CurrentValue.str?dpd->CurrentValue.str:""); + C_MEM (*content = strdup (dpd->CurrentValue.str?dpd->CurrentValue.str:"")); return GP_OK; default: sprintf(buf, "Unknown type 0x%04x", dpd->DataType); - *content = strdup (buf); + C_MEM (*content = strdup (buf)); return GP_OK; } } diff --git a/camlibs/ptp2/library.c b/camlibs/ptp2/library.c index 840497f5a..ac6084452 100644 --- a/camlibs/ptp2/library.c +++ b/camlibs/ptp2/library.c @@ -676,10 +676,7 @@ fixup_cached_deviceinfo (Camera *camera, PTPDeviceInfo *di) { /* The J5 so far goes up to 0xf01c */ #define NIKON_1_ADDITIONAL_DEVPROPS 29 if (i==di->DevicePropertiesSupported_len) { - di->DevicePropertiesSupported = realloc(di->DevicePropertiesSupported,sizeof(di->DevicePropertiesSupported[0])*(di->DevicePropertiesSupported_len + NIKON_1_ADDITIONAL_DEVPROPS+3)); - if (!di->DevicePropertiesSupported) { - C_MEM (di->DevicePropertiesSupported); - } + C_MEM (di->DevicePropertiesSupported = realloc(di->DevicePropertiesSupported,sizeof(di->DevicePropertiesSupported[0])*(di->DevicePropertiesSupported_len + NIKON_1_ADDITIONAL_DEVPROPS+3))); for (i=0;iDevicePropertiesSupported[i+di->DevicePropertiesSupported_len] = 0xf000 | i; @@ -7479,7 +7476,7 @@ camera_wait_for_event (Camera *camera, int timeout, /* objectinfo might not even be loaded yet, but this could be 0 / NULL ... but the compare will trigger */ oldparent = ob->oi.ParentObject; oldstorage = ob->oi.StorageID; - oldfn = strdup(ob->oi.Filename?ob->oi.Filename:""); + C_MEM (oldfn = strdup(ob->oi.Filename?ob->oi.Filename:"")); ob->flags &= ~PTPOBJECT_OBJECTINFO_LOADED; @@ -8569,7 +8566,7 @@ ptp_mtp_parse_metadata ( end = strstr (begin, propname2); if (!end) continue; *end = '\0'; - content = strdup(begin); + C_MEM (content = strdup(begin)); if (!content) { free (props); C_MEM (content); diff --git a/libgphoto2/gphoto2-widget.c b/libgphoto2/gphoto2-widget.c index 31768b05a..5ff46b766 100644 --- a/libgphoto2/gphoto2-widget.c +++ b/libgphoto2/gphoto2-widget.c @@ -401,7 +401,7 @@ gp_widget_set_value (CameraWidget *widget, const void *value) free (widget->value_string); } else widget->changed = 1; - widget->value_string = strdup ((char*)value); + C_MEM (widget->value_string = strdup ((char*)value)); return (GP_OK); case GP_WIDGET_RANGE: if (widget->value_float != *((float*)value)) { @@ -765,7 +765,7 @@ gp_widget_add_choice (CameraWidget *widget, const char *choice) (widget->type == GP_WIDGET_MENU)); C_MEM (widget->choice = realloc (widget->choice, sizeof(char*)*(widget->choice_count+1))); - widget->choice[widget->choice_count] = strdup(choice); + C_MEM (widget->choice[widget->choice_count] = strdup(choice)); widget->choice_count += 1; return (GP_OK); }