mirror of
https://github.com/osmarks/ngircd.git
synced 2025-05-16 14:14:09 +00:00
cleanups [from HEAD]
This commit is contained in:
parent
62f74db6f6
commit
2b4b416d2f
@ -12,7 +12,7 @@
|
||||
|
||||
#include "array.h"
|
||||
|
||||
static char UNUSED id[] = "$Id: array.c,v 1.11 2006/07/01 22:11:48 fw Exp $";
|
||||
static char UNUSED id[] = "$Id: array.c,v 1.11.2.1 2006/12/02 13:00:25 fw Exp $";
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
@ -66,10 +66,7 @@ array_alloc(array * a, size_t size, size_t pos)
|
||||
|
||||
assert(size > 0);
|
||||
|
||||
if (pos_plus1 < pos)
|
||||
return NULL;
|
||||
|
||||
if (!safemult_sizet(size, pos_plus1, &alloc))
|
||||
if (pos_plus1 == 0 || !safemult_sizet(size, pos_plus1, &alloc))
|
||||
return NULL;
|
||||
|
||||
if (a->allocated < alloc) {
|
||||
@ -263,7 +260,7 @@ array_get(array * a, size_t membersize, size_t pos)
|
||||
if (a->allocated < totalsize)
|
||||
return NULL;
|
||||
|
||||
return a->mem + pos * membersize;
|
||||
return a->mem + totalsize;
|
||||
}
|
||||
|
||||
|
||||
@ -283,16 +280,6 @@ array_free(array * a)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
array_free_wipe(array * a)
|
||||
{
|
||||
if (!array_UNUSABLE(a))
|
||||
memset(a->mem, 0, a->allocated);
|
||||
|
||||
array_free(a);
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
array_start(const array * const a)
|
||||
{
|
||||
@ -331,9 +318,6 @@ array_moveleft(array * a, size_t membersize, size_t pos)
|
||||
assert(a != NULL);
|
||||
assert(membersize > 0);
|
||||
|
||||
if (!pos)
|
||||
return;
|
||||
|
||||
if (!safemult_sizet(membersize, pos, &bytepos)) {
|
||||
a->used = 0;
|
||||
return;
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "portab.h"
|
||||
|
||||
static char UNUSED id[] = "$Id: resolve.c,v 1.24 2006/05/10 21:24:01 alex Exp $";
|
||||
static char UNUSED id[] = "$Id: resolve.c,v 1.24.2.1 2006/12/02 13:00:25 fw Exp $";
|
||||
|
||||
#include "imp.h"
|
||||
#include <assert.h>
|
||||
@ -340,33 +340,24 @@ Resolve_Shutdown( RES_STAT *s)
|
||||
GLOBAL size_t
|
||||
Resolve_Read( RES_STAT *s, void* readbuf, size_t buflen)
|
||||
{
|
||||
int err;
|
||||
ssize_t bytes_read;
|
||||
|
||||
assert(buflen > 0);
|
||||
|
||||
/* Read result from pipe */
|
||||
errno = 0;
|
||||
bytes_read = read(s->resolver_fd, readbuf, buflen);
|
||||
if (bytes_read < 0) {
|
||||
if (errno != EAGAIN) {
|
||||
err = errno;
|
||||
Log( LOG_CRIT, "Resolver: Can't read result: %s!", strerror(err));
|
||||
Resolve_Shutdown(s);
|
||||
errno = err;
|
||||
if (errno == EAGAIN)
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Resolve_Shutdown(s);
|
||||
if (bytes_read == 0) { /* EOF: lookup failed */
|
||||
Log( LOG_CRIT, "Resolver: Can't read result: %s!", strerror(errno));
|
||||
bytes_read = 0;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else if (bytes_read == 0)
|
||||
Log( LOG_DEBUG, "Resolver: Can't read result: EOF");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
Resolve_Shutdown(s);
|
||||
return (size_t)bytes_read;
|
||||
}
|
||||
/* -eof- */
|
||||
|
Loading…
x
Reference in New Issue
Block a user