projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update RPM requires
[yaz-moved-to-github.git]
/
src
/
odr_mem.c
diff --git
a/src/odr_mem.c
b/src/odr_mem.c
index
2cc6b4a
..
71a10e1
100644
(file)
--- a/
src/odr_mem.c
+++ b/
src/odr_mem.c
@@
-1,5
+1,5
@@
/* This file is part of the YAZ toolkit.
/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2013 Index Data
+ * Copyright (C) Index Data
* See the file LICENSE for details.
*/
/**
* See the file LICENSE for details.
*/
/**
@@
-65,11
+65,7
@@
size_t odr_total(ODR o)
Odr_oct *odr_create_Odr_oct(ODR o, const char *buf, int sz)
{
Odr_oct *p = (Odr_oct *) odr_malloc(o, sizeof(Odr_oct));
Odr_oct *odr_create_Odr_oct(ODR o, const char *buf, int sz)
{
Odr_oct *p = (Odr_oct *) odr_malloc(o, sizeof(Odr_oct));
- p->buf = (char *) odr_malloc(o, sz);
- memcpy(p->buf, buf, sz);
-#if OCT_SIZE
- p->size = sz;
-#endif
+ p->buf = odr_strdupn(o, buf, sz);
p->len = sz;
return p;
}
p->len = sz;
return p;
}
@@
-83,46
+79,47
@@
int odr_grow_block(ODR b, int min_bytes)
if (!b->op->can_grow)
return -1;
if (!b->op->can_grow)
return -1;
- if (!b->size)
+ if (!b->op->size)
togrow = 1024;
else
togrow = 1024;
else
- togrow = b->size;
+ togrow = b->op->size;
if (togrow < min_bytes)
togrow = min_bytes;
if (togrow < min_bytes)
togrow = min_bytes;
- if (b->size && !(b->buf =
- (char *) xrealloc(b->buf, b->size += togrow)))
+ if (b->op->size && !(b->op->buf =
+ (char *) xrealloc(b->op->buf, b->op->size += togrow)))
abort();
abort();
- else if (!b->size && !(b->buf = (char *) xmalloc(b->size = togrow)))
+ else if (!b->op->size && !(b->op->buf = (char *)
+ xmalloc(b->op->size = togrow)))
abort();
return 0;
}
abort();
return 0;
}
-int odr_write2(ODR o, const char *buf, int bytes)
+int odr_write(ODR o, const char *buf, int bytes)
{
{
- if (o->pos + bytes >= o->size && odr_grow_block(o, bytes))
+ if (o->op->pos + bytes >= o->op->size && odr_grow_block(o, bytes))
{
odr_seterror(o, OSPACE, 40);
return -1;
}
{
odr_seterror(o, OSPACE, 40);
return -1;
}
- memcpy(o->buf + o->pos, buf, bytes);
- o->pos += bytes;
- if (o->pos > o->top)
- o->top = o->pos;
+ memcpy(o->op->buf + o->op->pos, buf, bytes);
+ o->op->pos += bytes;
+ if (o->op->pos > o->op->top)
+ o->op->top = o->op->pos;
return 0;
}
int odr_seek(ODR o, int whence, int offset)
{
if (whence == ODR_S_CUR)
return 0;
}
int odr_seek(ODR o, int whence, int offset)
{
if (whence == ODR_S_CUR)
- offset += o->pos;
+ offset += o->op->pos;
else if (whence == ODR_S_END)
else if (whence == ODR_S_END)
- offset += o->top;
- if (offset > o->size && odr_grow_block(o, offset - o->size))
+ offset += o->op->top;
+ if (offset > o->op->size && odr_grow_block(o, offset - o->op->size))
{
odr_seterror(o, OSPACE, 41);
return -1;
}
{
odr_seterror(o, OSPACE, 41);
return -1;
}
- o->pos = offset;
+ o->op->pos = offset;
return 0;
}
return 0;
}