MFC revision 1.13
date: 2005/07/13 10:40:07; author: delphij; state: Exp; lines: +7 -4 Better memory handling: - It is acceptable to call free(3) when the given pointer itself is NULL, so we do not need to determine NULL before passing a pointer to free(3) - Handle failure of malloc(3) Submitted by: Dan Lukes <dan at obluda cz> PR: bin/83352 Approved by: re (scottl)
This commit is contained in:
parent
150c09eb2f
commit
63ac88b232
@ -97,8 +97,7 @@ cam_getccb(struct cam_device *dev)
|
||||
void
|
||||
cam_freeccb(union ccb *ccb)
|
||||
{
|
||||
if (ccb != NULL)
|
||||
free(ccb);
|
||||
free(ccb);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -708,8 +707,7 @@ cam_close_device(struct cam_device *dev)
|
||||
|
||||
cam_close_spec_device(dev);
|
||||
|
||||
if (dev != NULL)
|
||||
free(dev);
|
||||
free(dev);
|
||||
}
|
||||
|
||||
void
|
||||
@ -757,6 +755,11 @@ cam_device_dup(struct cam_device *device)
|
||||
}
|
||||
|
||||
newdev = malloc(sizeof(struct cam_device));
|
||||
if (newdev == NULL) {
|
||||
snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
|
||||
"%s: couldn't malloc CAM device structure", func_name);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
bcopy(device, newdev, sizeof(struct cam_device));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user