mirror of
https://github.com/osmarks/ngircd.git
synced 2025-05-16 22:24:08 +00:00
cleanups [from HEAD]
This commit is contained in:
parent
62f74db6f6
commit
2b4b416d2f
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include "array.h"
|
#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>
|
#include <assert.h>
|
||||||
|
|
||||||
@ -66,10 +66,7 @@ array_alloc(array * a, size_t size, size_t pos)
|
|||||||
|
|
||||||
assert(size > 0);
|
assert(size > 0);
|
||||||
|
|
||||||
if (pos_plus1 < pos)
|
if (pos_plus1 == 0 || !safemult_sizet(size, pos_plus1, &alloc))
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!safemult_sizet(size, pos_plus1, &alloc))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (a->allocated < alloc) {
|
if (a->allocated < alloc) {
|
||||||
@ -263,7 +260,7 @@ array_get(array * a, size_t membersize, size_t pos)
|
|||||||
if (a->allocated < totalsize)
|
if (a->allocated < totalsize)
|
||||||
return NULL;
|
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 *
|
void *
|
||||||
array_start(const array * const a)
|
array_start(const array * const a)
|
||||||
{
|
{
|
||||||
@ -331,9 +318,6 @@ array_moveleft(array * a, size_t membersize, size_t pos)
|
|||||||
assert(a != NULL);
|
assert(a != NULL);
|
||||||
assert(membersize > 0);
|
assert(membersize > 0);
|
||||||
|
|
||||||
if (!pos)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!safemult_sizet(membersize, pos, &bytepos)) {
|
if (!safemult_sizet(membersize, pos, &bytepos)) {
|
||||||
a->used = 0;
|
a->used = 0;
|
||||||
return;
|
return;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include "portab.h"
|
#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 "imp.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -340,33 +340,24 @@ Resolve_Shutdown( RES_STAT *s)
|
|||||||
GLOBAL size_t
|
GLOBAL size_t
|
||||||
Resolve_Read( RES_STAT *s, void* readbuf, size_t buflen)
|
Resolve_Read( RES_STAT *s, void* readbuf, size_t buflen)
|
||||||
{
|
{
|
||||||
int err;
|
|
||||||
ssize_t bytes_read;
|
ssize_t bytes_read;
|
||||||
|
|
||||||
assert(buflen > 0);
|
assert(buflen > 0);
|
||||||
|
|
||||||
/* Read result from pipe */
|
/* Read result from pipe */
|
||||||
errno = 0;
|
|
||||||
bytes_read = read(s->resolver_fd, readbuf, buflen);
|
bytes_read = read(s->resolver_fd, readbuf, buflen);
|
||||||
if (bytes_read < 0) {
|
if (bytes_read < 0) {
|
||||||
if (errno != EAGAIN) {
|
if (errno == EAGAIN)
|
||||||
err = errno;
|
|
||||||
Log( LOG_CRIT, "Resolver: Can't read result: %s!", strerror(err));
|
|
||||||
Resolve_Shutdown(s);
|
|
||||||
errno = err;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Resolve_Shutdown(s);
|
Log( LOG_CRIT, "Resolver: Can't read result: %s!", strerror(errno));
|
||||||
if (bytes_read == 0) { /* EOF: lookup failed */
|
bytes_read = 0;
|
||||||
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
else if (bytes_read == 0)
|
||||||
Log( LOG_DEBUG, "Resolver: Can't read result: EOF");
|
Log( LOG_DEBUG, "Resolver: Can't read result: EOF");
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
Resolve_Shutdown(s);
|
||||||
}
|
|
||||||
|
|
||||||
return (size_t)bytes_read;
|
return (size_t)bytes_read;
|
||||||
}
|
}
|
||||||
/* -eof- */
|
/* -eof- */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user