void replaceDetails()

in src/main/c/Posix/PosixHelperFunctions.c [99:142]


void replaceDetails(serialPort* port, const char* friendlyName, const char* description, const char* location, const char* serialNumber, const char* manufacturer, const char* deviceDriver, int vid, int pid, char isSymlink)
{
	// Update the storage structure
	port->enumerated = 1;
	port->vendorID = vid;
	port->productID = pid;
	port->isSymlink = isSymlink;
	char *newMemory = (char*)realloc(port->portLocation, strlen(location) + 1);
	if (newMemory)
	{
		port->portLocation = newMemory;
		strcpy(port->portLocation, location);
	}
	newMemory = (char*)realloc(port->friendlyName, strlen(friendlyName) + 1);
	if (newMemory)
	{
		port->friendlyName = newMemory;
		strcpy(port->friendlyName, friendlyName);
	}
	newMemory = (char*)realloc(port->serialNumber, strlen(serialNumber) + 1);
	if (newMemory)
	{
		port->serialNumber = newMemory;
		strcpy(port->serialNumber, serialNumber);
	}
	newMemory = (char*)realloc(port->manufacturer, strlen(manufacturer) + 1);
	if (newMemory)
	{
		port->manufacturer = newMemory;
		strcpy(port->manufacturer, manufacturer);
	}
	newMemory = (char*)realloc(port->deviceDriver, strlen(deviceDriver) + 1);
	if (newMemory)
	{
		port->deviceDriver = newMemory;
		strcpy(port->deviceDriver, deviceDriver);
	}
	newMemory = (char*)realloc(port->portDescription, strlen(description) + 1);
	if (newMemory)
	{
		port->portDescription = newMemory;
		strcpy(port->portDescription, description);
	}
}