* otherwise we're screwed, as selecting on non-overlapped handle
* will block.
*/
- fh->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
- fh->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
+ fh->oOverlapRead = GNUNET_new (OVERLAPPED);
+ fh->oOverlapWrite = GNUNET_new (OVERLAPPED);
fh->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
fh->oOverlapWrite->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
}
p->fd[0]->type = GNUNET_DISK_HANLDE_TYPE_PIPE;
p->fd[1]->type = GNUNET_DISK_HANLDE_TYPE_PIPE;
- p->fd[0]->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
- p->fd[0]->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
- p->fd[1]->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
- p->fd[1]->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
+ p->fd[0]->oOverlapRead = GNUNET_new (OVERLAPPED);
+ p->fd[0]->oOverlapWrite = GNUNET_new (OVERLAPPED);
+ p->fd[1]->oOverlapRead = GNUNET_new (OVERLAPPED);
+ p->fd[1]->oOverlapWrite = GNUNET_new (OVERLAPPED);
p->fd[0]->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
p->fd[0]->oOverlapWrite->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
if (p->fd[0]->h != INVALID_HANDLE_VALUE)
{
p->fd[0]->type = GNUNET_DISK_HANLDE_TYPE_PIPE;
- p->fd[0]->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
- p->fd[0]->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
+ p->fd[0]->oOverlapRead = GNUNET_new (OVERLAPPED);
+ p->fd[0]->oOverlapWrite = GNUNET_new (OVERLAPPED);
p->fd[0]->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
p->fd[0]->oOverlapWrite->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
}
if (p->fd[1]->h != INVALID_HANDLE_VALUE)
{
p->fd[1]->type = GNUNET_DISK_HANLDE_TYPE_PIPE;
- p->fd[1]->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
- p->fd[1]->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
+ p->fd[1]->oOverlapRead = GNUNET_new (OVERLAPPED);
+ p->fd[1]->oOverlapWrite = GNUNET_new (OVERLAPPED);
p->fd[1]->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
p->fd[1]->oOverlapWrite->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
}
* @param fh GNUnet file descriptor
* @param dst destination buffer
* @param dst_len length of dst
- * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/
int
GNUNET_DISK_internal_file_handle_ (const struct GNUNET_DISK_FileHandle *fh,
void *dst, size_t dst_len)
{
+ if (NULL == fh)
+ return GNUNET_SYSERR;
#ifdef MINGW
if (dst_len < sizeof (HANDLE))
return GNUNET_SYSERR;