X-Git-Url: http://git.tuebingen.mpg.de/?p=osl.git;a=blobdiff_plain;f=osl_core.h;h=df32b60a875b4c4448f991823ab1e974d5a4f0c7;hp=87a118803ea4165ab2a767dbda1f7607a1a8b91b;hb=7d53d2f571da94ec9caf85fb456118ebee85fcf9;hpb=5952112a37ecdaedf3b76e08f97d307f1056c512 diff --git a/osl_core.h b/osl_core.h index 87a1188..df32b60 100644 --- a/osl_core.h +++ b/osl_core.h @@ -7,11 +7,9 @@ /** \file osl_core.h Object storage layer details, not visible to users. */ #include "rbtree.h" -#include "osl.h" -#include "string.h" #include "hash.h" -static __must_check __printf_1_2 __malloc char *make_message(const char *fmt, ...); +__must_check __printf_1_2 __malloc char *make_message(const char *fmt, ...); /** Internal representation of a column of an osl table. */ struct osl_column { @@ -85,7 +83,6 @@ int init_table_structure(const struct osl_table_description *desc, int row_is_invalid(struct osl_table *t, uint32_t row_num); int get_mapped_object(const struct osl_table *t, unsigned col_num, uint32_t row_num, struct osl_object *obj); -int para_truncate(const char *filename, off_t size); int unmap_table(struct osl_table *t, enum osl_close_flags flags); int init_rbtrees(struct osl_table *t); @@ -262,7 +259,7 @@ _static_inline_ int get_row_index(const struct osl_table *t, uint32_t row_num, index_offset = t->index_header_size + t->row_index_size * row_num; if (index_offset + 8 > t->index_map.size) { *row_index = NULL; - return -E_INDEX_CORRUPTION; + return -E_OSL_INDEX_CORRUPTION; } *row_index = (char *)(t->index_map.data) + index_offset; return 1; @@ -306,8 +303,8 @@ _static_inline_ int get_cell_index(const struct osl_table *t, uint32_t row_num, _static_inline_ void update_cell_index(char *row_index, struct osl_column *col, uint32_t map_size, uint32_t object_size) { - write_u32(row_index + col->index_offset, map_size - object_size - 1); - write_u32(row_index + col->index_offset + 4, object_size + 1); + write_u32(row_index + col->index_offset, map_size - object_size); + write_u32(row_index + col->index_offset + 4, object_size); } /** @@ -324,8 +321,11 @@ _static_inline_ void update_cell_index(char *row_index, struct osl_column *col, _static_inline_ char *disk_storage_path(const struct osl_table *t, unsigned col_num, const char *ds_name) { - char *dirname = column_filename(t, col_num); - char *filename = make_message("%s/%s", dirname, ds_name); + char *filename, *dirname = column_filename(t, col_num); + + if (!dirname) + return NULL; + filename = make_message("%s/%s", dirname, ds_name); free(dirname); return filename; } @@ -398,13 +398,13 @@ _static_inline_ int next_rbtree_column(int col_num, const struct osl_table *t, * * \param num_rbtrees The number of rbtrees for this row. * - * \return A pointer to a zeroed-out area suitable for holding an osl row - * with \a num_rbtrees rbtree columns. + * \return A pointer to a zeroed-out area suitable for holding an osl row with + * \a num_rbtrees rbtree columns or \p NULL if no memory could be allocated. */ _static_inline_ struct osl_row *allocate_row(unsigned num_rbtrees) { size_t s = RB_NODES_OFFSET + num_rbtrees * sizeof(struct rb_node); - return para_calloc(s); + return calloc(1, s); } /** @@ -469,24 +469,7 @@ _static_inline_ char *disk_storage_name_of_hash(const struct osl_table *t, HASH_ hash_to_asc(hash, asc); if (t->desc->flags & OSL_LARGE_TABLE) return make_message("%.2s/%s", asc, asc + 2); - return para_strdup(asc); -} - -/** - * A wrapper for rename(2). - * - * \param old_path The source path. - * \param new_path The destination path. - * - * \return Standard. - * - * \sa rename(2). - */ -_static_inline_ int para_rename(const char *old_path, const char *new_path) -{ - if (rename(old_path, new_path) < 0) - return -ERRNO_TO_ERROR(errno); - return 1; + return strdup(asc); } /**