diff options
| author | Lars Hanisch <dvb@flensrocker.de> | 2010-12-04 10:54:24 +0100 |
|---|---|---|
| committer | Lars Hanisch <dvb@flensrocker.de> | 2010-12-04 10:54:24 +0100 |
| commit | 89508dfcc23ce215b97b46cbb5b8e9062235986c (patch) | |
| tree | edd38c311bf939d429dad4a78a55b20b818e0886 | |
| parent | 3a403a9edd8929f8cc2613b725246996cf39c9c0 (diff) | |
| download | vdr-plugin-pvrinput-89508dfcc23ce215b97b46cbb5b8e9062235986c.tar.gz vdr-plugin-pvrinput-89508dfcc23ce215b97b46cbb5b8e9062235986c.tar.bz2 | |
use cString::sprintf instead of standard sprintf
So we don't have to handle the memory allocation on our own.
| -rwxr-xr-x | device.c | 22 | ||||
| -rw-r--r-- | menu.c | 3 |
2 files changed, 9 insertions, 16 deletions
@@ -216,14 +216,13 @@ cPvrDevice::~cPvrDevice() bool cPvrDevice::Probe(int DeviceNumber) { - char device[256]; struct v4l2_capability vcap; struct v4l2_format vfmt; int v4l2_fd; bool found = false; memset(&vcap, 0, sizeof(vcap)); memset(&vfmt, 0, sizeof(vfmt)); - sprintf(device, "/dev/video%d", DeviceNumber); + cString device = cString::sprintf("/dev/video%d", DeviceNumber); v4l2_fd = open(device, O_RDONLY); if (v4l2_fd >= 0) { IOCTL(v4l2_fd, VIDIOC_QUERYCAP, &vcap); @@ -606,22 +605,19 @@ void cPvrDevice::SetEncoderState(eEncState state) log(pvrDEBUG2, "cPvrDevice::SetEncoderState (eStop): /dev/video%d (%s) is closed", number, CARDNAME[cardname]); pvrusb2_ready = false; - char *devName; - if (asprintf(&devName, "/dev/video%d", number) != -1) - v4l2_fd = open(devName, O_RDWR); //reopen for tuning + cString devName = cString::sprintf("/dev/video%d", number); + v4l2_fd = open(devName, O_RDWR); //reopen for tuning if (v4l2_fd < 0) { log(pvrERROR, "cPvrDevice::SetEncoderState(eStop): error reopening %s (%s): %d:%s", - CARDNAME[cardname], devName, errno, strerror(errno)); - free(devName); + CARDNAME[cardname], *devName, errno, strerror(errno)); retry_count--; if (retry_count > 0) goto retry; } else { log(pvrDEBUG2, "cPvrDevice::SetEncoderState (eStop): %s (%s) successfully re-opened", - devName, CARDNAME[cardname]); + *devName, CARDNAME[cardname]); pvrusb2_ready = true; - free(devName); } } } @@ -822,14 +818,12 @@ bool cPvrDevice::OpenDvr(void) if (radio_dev < 0) return false; //no hardware support. if (radio_fd < 0) { - char *devName; - if (asprintf(&devName, "/dev/radio%d", radio_dev) != -1) - radio_fd = open(devName, O_RDONLY); + cString devName = cString::sprintf("/dev/radio%d", radio_dev); + radio_fd = open(devName, O_RDONLY); if (radio_fd < 0) { - log(pvrERROR, "Error opening FM radio device %s: %s", devName, strerror(errno)); + log(pvrERROR, "Error opening FM radio device %s: %s", *devName, strerror(errno)); return false; } - free(devName); usleep(100000); /* 100msec */ SetControlValue(&PvrSetup.AudioVolumeFM, PvrSetup.AudioVolumeFM.value); } @@ -304,8 +304,7 @@ void cPvrMenuMain::Draw(void) osd->DrawRectangle(0, titleHeight, border - 1, height - 1, clrWhite); osd->DrawRectangle(0, height - border, width - 1, height - 1, clrWhite); osd->DrawRectangle(width - border, titleHeight, width - 1, height - 1, clrWhite); - char strpercentvalue[4]; - sprintf(strpercentvalue, "%d%%", IntVal2Percent(localvalue, localminimum, localmaximum)); + cString strpercentvalue = cString::sprintf("%d%%", IntVal2Percent(localvalue, localminimum, localmaximum)); osd->DrawText(width - font->Width("100%") - border - margin - 1, border + margin + titleHeight, strpercentvalue, |
