s = malloc(len1 + len2 + 1);
if (s) {
- strncpy((char *)s, (char *)n1, len1);
- strncpy((char *)s + len1, (char *)n2, len2);
+ memcpy((char *)s, (char *)n1, len1);
+ memcpy((char *)s + len1, (char *)n2, len2);
s[len1 + len2] = '\0';
} else {
die("can not allocate memory for \"s\" in tinysvcmdns");
s = malloc(len + 2);
if (s) {
s[0] = len;
- strncpy((char *)s + 1, txt, len);
+ memcpy((char *)s + 1, txt, len);
s[len + 1] = '\0';
} else {
die("can not allocate memory for \"s\" 2 in tinysvcmdns.");
if (label == NULL)
return NULL;
- strncpy((char *)label + 1, name, len);
+ memcpy((char *)label + 1, name, len);
label[len + 1] = '\0';
p = label;
// main loop to receive, process and send out MDNS replies
// also handles MDNS service announces
-static void main_loop(struct mdnsd *svr) {
+void* main_loop(struct mdnsd *svr) {
fd_set sockfd_set;
int max_fd = svr->sockfd;
char notify_buf[2]; // buffer for reading of notify_pipe
close_pipe(svr->sockfd);
svr->stop_flag = 2;
+ return NULL;
}
/////////////////////////////////////////////////////
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- if (pthread_create(&tid, &attr, (void *(*)(void *))main_loop, (void *)server) != 0) {
+ if (pthread_create(&tid, &attr, (void * (*)(void *))&main_loop, (void *)server) != 0) {
pthread_mutex_destroy(&server->data_lock);
free(server);
return NULL;