return buf;
}
-/* strdup with a limit */
-char *pstrdup(const char *str, size_t buf_size)
-{
- size_t len;
- char *buf;
-
- len = MIN(buf_size, strlen(str));
- buf = qemu_malloc(len);
- pstrcpy(buf, len, str);
- return buf;
-}
-
int strstart(const char *str, const char *val, const char **ptr)
{
const char *p, *q;
hci->device.inquiry_scan = 0;
hci->device.page_scan = 0;
if (hci->device.lmp_name)
- qemu_free((void *) hci->device.lmp_name);
+ free((void *) hci->device.lmp_name);
hci->device.lmp_name = 0;
hci->device.class[0] = 0x00;
hci->device.class[1] = 0x00;
params.status = HCI_SUCCESS;
memset(params.name, 0, sizeof(params.name));
if (hci->device.lmp_name)
- pstrcpy(params.name, sizeof(params.name), hci->device.lmp_name);
+ strncpy(params.name, hci->device.lmp_name, sizeof(params.name));
bt_hci_event_complete(hci, ¶ms, READ_LOCAL_NAME_RP_SIZE);
}
LENGTH_CHECK(change_local_name);
if (hci->device.lmp_name)
- qemu_free((void *) hci->device.lmp_name);
- hci->device.lmp_name = pstrdup(PARAM(change_local_name, name),
+ free((void *) hci->device.lmp_name);
+ hci->device.lmp_name = strndup(PARAM(change_local_name, name),
sizeof(PARAM(change_local_name, name)));
bt_hci_event_complete_status(hci, HCI_SUCCESS);
break;
bt_device_done(&hci->device);
if (hci->device.lmp_name)
- qemu_free((void *) hci->device.lmp_name);
+ free((void *) hci->device.lmp_name);
/* Be gentle and send DISCONNECT to all connected peers and those
* currently waiting for us to accept or reject a connection request.
/* cutils.c */
void pstrcpy(char *buf, int buf_size, const char *str);
char *pstrcat(char *buf, int buf_size, const char *s);
-char *pstrdup(const char *str, size_t buf_size);
int strstart(const char *str, const char *val, const char **ptr);
int stristart(const char *str, const char *val, const char **ptr);
time_t mktimegm(struct tm *tm);