Logo Search packages:      
Sourcecode: libgphoto2 version File versions  Download package

int gp_port_new ( GPPort **  port  ) 

Create new GPPort.

Allocate and initialize the memory for a new GPPort.

After you called this function, you probably want to call gp_port_set_info in order to make the newly created port functional.

Parameters:
port Pointer the GPPort* pointer
Returns:
a gphoto2 error code

Definition at line 83 of file gphoto2-port.c.

References CHECK_NULL, GP_ERROR_NO_MEMORY, gp_log(), GP_LOG_DEBUG, GP_OK, and gp_port_free().

Referenced by gp_abilities_list_detect(), and gp_camera_new().

{
      CHECK_NULL (port);

        gp_log (GP_LOG_DEBUG, "gphoto2-port", _("Creating new device..."));

      *port = malloc (sizeof (GPPort));
        if (!(*port))
            return (GP_ERROR_NO_MEMORY);
        memset (*port, 0, sizeof (GPPort));

      (*port)->pc = malloc (sizeof (GPPortPrivateCore));
      if (!(*port)->pc) {
            gp_port_free (*port);
            return (GP_ERROR_NO_MEMORY);
      }
      memset ((*port)->pc, 0, sizeof (GPPortPrivateCore));

        return (GP_OK);
}


Generated by  Doxygen 1.6.0   Back to index