return -1;
m_strncpy(group, ssizeof(group), line, p - line);
- if ((data = (nntp_data_t *) hash_find (news->newsgroups, group)) == NULL) {
- data = xmalloc(sizeof(nntp_data_t) + m_strlen(group) + 1);
- data->group = (char *) data + sizeof (nntp_data_t);
- strcpy (data->group, group);
+ if ((data = hash_find(news->newsgroups, group)) == NULL) {
+ data = nntp_data_new();
+ data->group = m_strdup(group);
data->nserv = news;
data->deleted = 1;
if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
- hash_insert (news->newsgroups, data->group, data);
+ hash_insert(news->newsgroups, data->group, data);
nntp_data_list_append(&news->list, data);
} else {
p_delete(&data->entries);
news->newgroups_time = m;
}
else if (news->newsgroups) {
- if ((data = (nntp_data_t *) hash_find (news->newsgroups, buf)) == NULL) {
- data = xmalloc(sizeof(nntp_data_t) + m_strlen(buf) + 1);
- data->group = (char *) data + sizeof (nntp_data_t);
- strcpy (data->group, buf);
+ if ((data = hash_find (news->newsgroups, buf)) == NULL) {
+ data = nntp_data_new();
+ data->group = m_strdup(buf);
data->nserv = news;
data->deleted = 1;
if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
if (!news || !news->newsgroups || !group || !*group)
return NULL;
if (!(data = (nntp_data_t *) hash_find (news->newsgroups, group))) {
- data = xmalloc(sizeof(nntp_data_t) + m_strlen(group) + 1);
- data->group = (char *) data + sizeof (nntp_data_t);
- strcpy (data->group, group);
+ data = nntp_data_new();
+ data->group = m_strdup(group);
data->nserv = news;
data->deleted = 1;
if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
CurrentNewsSrv = serv;
/* create NNTP-specific state struct if nof found in list */
- if ((nntp_data = (nntp_data_t *) hash_find (serv->newsgroups, buf)) == NULL) {
- nntp_data = xmalloc(sizeof(nntp_data_t) + m_strlen(buf) + 1);
- nntp_data->group = (char *) nntp_data + sizeof (nntp_data_t);
- strcpy (nntp_data->group, buf);
- hash_insert (serv->newsgroups, nntp_data->group, nntp_data);
+ if ((nntp_data = hash_find(serv->newsgroups, buf)) == NULL) {
+ nntp_data = nntp_data_new();
+ nntp_data->group = m_strdup(buf);
+ hash_insert(serv->newsgroups, nntp_data->group, nntp_data);
nntp_data_list_append(&serv->list, nntp_data);
}
ctx->data = nntp_data;
p_delete(&data->entries);
p_delete(&data->desc);
p_delete(&data->cache);
+ p_delete(&data->group);
nntp_free_acache(data);
}
sscanf (buf, "%s %d %d %c %[^\n]", group, &last, &first, &mod, desc);
if (!group)
return 0;
- if ((nntp_data = (nntp_data_t *) hash_find (s->newsgroups, group)) == NULL) {
+ if ((nntp_data = hash_find(s->newsgroups, group)) == NULL) {
n++;
- nntp_data = xmalloc(sizeof(nntp_data_t) + m_strlen(group) + 1);
- nntp_data->group = (char *) nntp_data + sizeof (nntp_data_t);
- strcpy (nntp_data->group, group);
+ nntp_data = nntp_data_new();
+ nntp_data->group = m_strdup(group);
nntp_data->nserv = s;
if (s->newsgroups->nelem < s->newsgroups->curnelem * 2)
hash_resize (s->newsgroups, s->newsgroups->nelem * 2);
- hash_insert (s->newsgroups, nntp_data->group, nntp_data);
+ hash_insert(s->newsgroups, nntp_data->group, nntp_data);
nntp_data_list_append(&s->list, nntp_data);
}
nntp_data->deleted = 0;