svn rev #21936: trunk/src/util/support/
raeburn@MIT.EDU
raeburn at MIT.EDU
Mon Feb 9 18:01:00 EST 2009
http://src.mit.edu/fisheye/changelog/krb5/?cs=21936
Commit By: raeburn
Log Message:
Adjust names to not conflict with Windows headers.
Changed Files:
U trunk/src/util/support/k5buf-int.h
U trunk/src/util/support/k5buf.c
Modified: trunk/src/util/support/k5buf-int.h
===================================================================
--- trunk/src/util/support/k5buf-int.h 2009-02-09 22:59:00 UTC (rev 21935)
+++ trunk/src/util/support/k5buf-int.h 2009-02-09 23:00:59 UTC (rev 21936)
@@ -46,6 +46,6 @@
#define SPACE_MAX (SIZE_MAX / 2) /* rounds down, since SIZE_MAX is odd */
/* Buffer type values. */
-enum { FIXED, DYNAMIC, ERROR };
+enum { BUFTYPE_FIXED, BUFTYPE_DYNAMIC, BUFTYPE_ERROR };
#endif /* K5BUF_INT_H */
Modified: trunk/src/util/support/k5buf.c
===================================================================
--- trunk/src/util/support/k5buf.c 2009-02-09 22:59:00 UTC (rev 21935)
+++ trunk/src/util/support/k5buf.c 2009-02-09 23:00:59 UTC (rev 21936)
@@ -36,8 +36,8 @@
/* Structure invariants:
- buftype is FIXED, DYNAMIC, or ERROR
- if buftype is not ERROR:
+ buftype is BUFTYPE_FIXED, BUFTYPE_DYNAMIC, or BUFTYPE_ERROR
+ if buftype is not BUFTYPE_ERROR:
space > 0
space <= floor(SIZE_MAX / 2) (to fit within ssize_t)
len < space
@@ -52,13 +52,13 @@
size_t new_space;
char *new_data;
- if (buf->buftype == ERROR)
+ if (buf->buftype == BUFTYPE_ERROR)
return 0;
if (buf->space - 1 - buf->len >= len) /* Enough room already. */
return 1;
- if (buf->buftype == FIXED) /* Can't resize a fixed buffer. */
+ if (buf->buftype == BUFTYPE_FIXED) /* Can't resize a fixed buffer. */
goto error_exit;
- assert(buf->buftype == DYNAMIC);
+ assert(buf->buftype == BUFTYPE_DYNAMIC);
new_space = buf->space * 2;
while (new_space <= SPACE_MAX && new_space - buf->len - 1 < len)
new_space *= 2;
@@ -72,18 +72,18 @@
return 1;
error_exit:
- if (buf->buftype == DYNAMIC) {
+ if (buf->buftype == BUFTYPE_DYNAMIC) {
free(buf->data);
buf->data = NULL;
}
- buf->buftype = ERROR;
+ buf->buftype = BUFTYPE_ERROR;
return 0;
}
void krb5int_buf_init_fixed(struct k5buf *buf, char *data, size_t space)
{
assert(space > 0);
- buf->buftype = FIXED;
+ buf->buftype = BUFTYPE_FIXED;
buf->data = data;
buf->space = space;
buf->len = 0;
@@ -92,11 +92,11 @@
void krb5int_buf_init_dynamic(struct k5buf *buf)
{
- buf->buftype = DYNAMIC;
+ buf->buftype = BUFTYPE_DYNAMIC;
buf->space = DYNAMIC_INITIAL_SIZE;
buf->data = malloc(buf->space);
if (buf->data == NULL) {
- buf->buftype = ERROR;
+ buf->buftype = BUFTYPE_ERROR;
return;
}
buf->len = 0;
@@ -124,24 +124,24 @@
size_t remaining;
char *tmp;
- if (buf->buftype == ERROR)
+ if (buf->buftype == BUFTYPE_ERROR)
return;
remaining = buf->space - buf->len;
- if (buf->buftype == FIXED) {
+ if (buf->buftype == BUFTYPE_FIXED) {
/* Format the data directly into the fixed buffer. */
va_start(ap, fmt);
r = vsnprintf(buf->data + buf->len, remaining, fmt, ap);
va_end(ap);
if (SNPRINTF_OVERFLOW(r, remaining))
- buf->buftype = ERROR;
+ buf->buftype = BUFTYPE_ERROR;
else
buf->len += (unsigned int) r;
return;
}
/* Optimistically format the data directly into the dynamic buffer. */
- assert(buf->buftype == DYNAMIC);
+ assert(buf->buftype == BUFTYPE_DYNAMIC);
va_start(ap, fmt);
r = vsnprintf(buf->data + buf->len, remaining, fmt, ap);
va_end(ap);
@@ -159,7 +159,7 @@
r = vsnprintf(buf->data + buf->len, remaining, fmt, ap);
va_end(ap);
if (SNPRINTF_OVERFLOW(r, remaining)) /* Shouldn't ever happen. */
- buf->buftype = ERROR;
+ buf->buftype = BUFTYPE_ERROR;
else
buf->len += (unsigned int) r;
return;
@@ -171,7 +171,7 @@
r = vasprintf(&tmp, fmt, ap);
va_end(ap);
if (r < 0) {
- buf->buftype = ERROR;
+ buf->buftype = BUFTYPE_ERROR;
return;
}
if (ensure_space(buf, r)) {
@@ -184,7 +184,7 @@
void krb5int_buf_truncate(struct k5buf *buf, size_t len)
{
- if (buf->buftype == ERROR)
+ if (buf->buftype == BUFTYPE_ERROR)
return;
assert(len <= buf->len);
buf->len = len;
@@ -194,20 +194,20 @@
char *krb5int_buf_data(struct k5buf *buf)
{
- return (buf->buftype == ERROR) ? NULL : buf->data;
+ return (buf->buftype == BUFTYPE_ERROR) ? NULL : buf->data;
}
ssize_t krb5int_buf_len(struct k5buf *buf)
{
- return (buf->buftype == ERROR) ? -1 : (ssize_t) buf->len;
+ return (buf->buftype == BUFTYPE_ERROR) ? -1 : (ssize_t) buf->len;
}
void krb5int_free_buf(struct k5buf *buf)
{
- if (buf->buftype == ERROR)
+ if (buf->buftype == BUFTYPE_ERROR)
return;
- assert(buf->buftype == DYNAMIC);
+ assert(buf->buftype == BUFTYPE_DYNAMIC);
free(buf->data);
buf->data = NULL;
- buf->buftype = ERROR;
+ buf->buftype = BUFTYPE_ERROR;
}
More information about the cvs-krb5
mailing list