aboutsummaryrefslogtreecommitdiff
path: root/db2/db/db_ret.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-06-13 13:36:34 +0000
committerUlrich Drepper <drepper@redhat.com>1999-06-13 13:36:34 +0000
commitec239360d13518a13f572b635d036c7d10028010 (patch)
treebdb5111363f45d2107849c2456b575d72779174c /db2/db/db_ret.c
parentfc3703521650a9b6db910a50c4fc0f410496e134 (diff)
downloadglibc-ec239360d13518a13f572b635d036c7d10028010.tar
glibc-ec239360d13518a13f572b635d036c7d10028010.tar.gz
glibc-ec239360d13518a13f572b635d036c7d10028010.tar.bz2
glibc-ec239360d13518a13f572b635d036c7d10028010.zip
Update.
* db2/Makefile (distribute): Remove files which do not exist anymore.
Diffstat (limited to 'db2/db/db_ret.c')
-rw-r--r--db2/db/db_ret.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/db2/db/db_ret.c b/db2/db/db_ret.c
index 9d9b599ad6..9f0d0ecf8d 100644
--- a/db2/db/db_ret.c
+++ b/db2/db/db_ret.c
@@ -8,7 +8,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)db_ret.c 10.13 (Sleepycat) 5/7/98";
+static const char sccsid[] = "@(#)db_ret.c 10.16 (Sleepycat) 10/4/98";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
@@ -93,6 +93,8 @@ __db_retcopy(dbt, data, len, memp, memsize, db_malloc)
u_int32_t *memsize;
void *(*db_malloc) __P((size_t));
{
+ int ret;
+
/* If returning a partial record, reset the length. */
if (F_ISSET(dbt, DB_DBT_PARTIAL)) {
data = (u_int8_t *)data + dbt->doff;
@@ -120,9 +122,6 @@ __db_retcopy(dbt, data, len, memp, memsize, db_malloc)
* guarantees consistency, i.e., the application can always free memory
* without concern as to how many bytes of the record were requested.
*
- * XXX
- * Never allocate 0 bytes, it's known to make malloc/realloc unhappy.
- *
* Use the memory specified by the application: DB_DBT_USERMEM.
*
* !!!
@@ -130,11 +129,8 @@ __db_retcopy(dbt, data, len, memp, memsize, db_malloc)
* memory pointer is allowed to be NULL.
*/
if (F_ISSET(dbt, DB_DBT_MALLOC)) {
- dbt->data = db_malloc == NULL ?
- (void *)__db_malloc(len) :
- (void *)db_malloc(len + 1);
- if (dbt->data == NULL)
- return (ENOMEM);
+ if ((ret = __os_malloc(len, db_malloc, &dbt->data)) != 0)
+ return (ret);
} else if (F_ISSET(dbt, DB_DBT_USERMEM)) {
if (len != 0 && (dbt->data == NULL || dbt->ulen < len))
return (ENOMEM);
@@ -142,12 +138,9 @@ __db_retcopy(dbt, data, len, memp, memsize, db_malloc)
return (EINVAL);
} else {
if (len != 0 && (*memsize == 0 || *memsize < len)) {
- *memp = *memp == NULL ?
- (void *)__db_malloc(len) :
- (void *)__db_realloc(*memp, len);
- if (*memp == NULL) {
+ if ((ret = __os_realloc(memp, len)) != 0) {
*memsize = 0;
- return (ENOMEM);
+ return (ret);
}
*memsize = len;
}