INSTALL: Explain how to update the library cache on MacOS.
[osl.git] / osl.c
diff --git a/osl.c b/osl.c
index 67160d2b3bb14539edf1cd5f8b886d55940d0f63..e31811b9c57eb0d897aee1c92c41b72cb35a97cc 100644 (file)
--- a/osl.c
+++ b/osl.c
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2007-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2007-2009 Andre Noll <maan@tuebingen.mpg.de>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
 #include "util.h"
 #include "osl_core.h"
 
 #include "util.h"
 #include "osl_core.h"
 
-/* Taken from Drepper: How to write shared libraries, Appendix B. */
+/*
+ * Taken from Drepper: How to write shared libraries, Appendix B.
+ *
+ * The main reason for this rather fancy implementation of strerror() is to
+ * avoid having an array of pointers. This is desirable because initialized
+ * pointer variables increase the startup time of the library due to the
+ * processing of relocations.
+ */
 #include <stddef.h>
 #define MSGSTRFIELD(line) MSGSTRFIELD1(line)
 #define MSGSTRFIELD1(line) str##line
 #include <stddef.h>
 #define MSGSTRFIELD(line) MSGSTRFIELD1(line)
 #define MSGSTRFIELD1(line) str##line
@@ -277,6 +284,9 @@ int init_table_structure(const struct osl_table_description *desc,
                ret = -E_OSL_BAD_STORAGE_FLAGS;
                if (st == OSL_DISK_STORAGE && sf & OSL_RBTREE)
                        goto err;
                ret = -E_OSL_BAD_STORAGE_FLAGS;
                if (st == OSL_DISK_STORAGE && sf & OSL_RBTREE)
                        goto err;
+               if ((sf & OSL_RBTREE) && !(sf & OSL_UNIQUE))
+                       WARNING_LOG("invalid storage flags for column %s: "
+                               "OSL_RBTREE && !OSL_UNIQUE\n", cd->name);
                ret = -E_OSL_BAD_STORAGE_SIZE;
                if (sf & OSL_FIXED_SIZE && !cd->data_size)
                        goto err;
                ret = -E_OSL_BAD_STORAGE_SIZE;
                if (sf & OSL_FIXED_SIZE && !cd->data_size)
                        goto err;
@@ -516,7 +526,7 @@ static int create_table_index(struct osl_table *t)
                strcpy(buf + offset + IDX_CD_NAME, cd->name);
                offset += index_column_description_size(cd->name);
        }
                strcpy(buf + offset + IDX_CD_NAME, cd->name);
                offset += index_column_description_size(cd->name);
        }
-       assert(offset = size);
+       assert(offset == size);
        filename = index_filename(t->desc);
        if (filename)
                ret = write_file(filename, buf, size);
        filename = index_filename(t->desc);
        if (filename)
                ret = write_file(filename, buf, size);
@@ -1569,7 +1579,8 @@ __export int osl_update_object(struct osl_table *t, const struct osl_row *r,
        }
        remove_rb_node(t, col_num, r);
        if (cd->storage_type == OSL_NO_STORAGE) { /* TODO: If fixed size, reuse object? */
        }
        remove_rb_node(t, col_num, r);
        if (cd->storage_type == OSL_NO_STORAGE) { /* TODO: If fixed size, reuse object? */
-               free(r->volatile_objects[col->volatile_num].data);
+               if (!(cd->storage_flags & OSL_DONT_FREE))
+                       free(r->volatile_objects[col->volatile_num].data);
                r->volatile_objects[col->volatile_num] = *obj;
        } else if (cd->storage_type == OSL_DISK_STORAGE) {
                char *ds_name;
                r->volatile_objects[col->volatile_num] = *obj;
        } else if (cd->storage_type == OSL_DISK_STORAGE) {
                char *ds_name;
@@ -1698,6 +1709,7 @@ __export int osl_get_nth_row(const struct osl_table *t, unsigned col_num,
        unsigned num_rows;
        int ret;
 
        unsigned num_rows;
        int ret;
 
+       *result = NULL;
        if (n == 0)
                return -E_OSL_RB_KEY_NOT_FOUND;
        ret = osl_get_num_rows(t, &num_rows);
        if (n == 0)
                return -E_OSL_RB_KEY_NOT_FOUND;
        ret = osl_get_num_rows(t, &num_rows);