Logo Search packages:      
Sourcecode: libgphoto2 version File versions

int gp_camera_new ( Camera **  camera  ) 

gp_camera_new: :

Allocates the memory for a Camera.

Return value: a gphoto2 error code

Definition at line 332 of file gphoto2-camera.c.

References gp_camera_free(), and gp_filesystem_new().

{
      int result;

      CHECK_NULL (camera);

        *camera = malloc (sizeof (Camera));
      if (!*camera) 
            return (GP_ERROR_NO_MEMORY);
      memset (*camera, 0, sizeof (Camera));

        (*camera)->functions = malloc(sizeof(CameraFunctions));
      if (!(*camera)->functions) {
            gp_camera_free (*camera);
            return (GP_ERROR_NO_MEMORY);
      }
      memset ((*camera)->functions, 0, sizeof (CameraFunctions));

      (*camera)->pc = malloc (sizeof (CameraPrivateCore));
      if (!(*camera)->pc) {
            gp_camera_free (*camera);
            return (GP_ERROR_NO_MEMORY);
      }
      memset ((*camera)->pc, 0, sizeof (CameraPrivateCore));

        (*camera)->pc->ref_count = 1;

      /* Create the filesystem */
      result = gp_filesystem_new (&(*camera)->fs);
      if (result != GP_OK) {
            gp_camera_free (*camera);
            return (result);
      }

      /* Create the port */
      result = gp_port_new (&(*camera)->port);
      if (result < 0) {
            gp_camera_free (*camera);
            return (result);
      }

        return(GP_OK);
}


Generated by  Doxygen 1.6.0   Back to index