Logo Search packages:      
Sourcecode: ldb version File versions  Download package

struct ldb_val ldb_val_dup ( void *  mem_ctx,
const struct ldb_val v 
) [read]

Duplicate an ldb_val structure

This function copies an ldb value structure.

Parameters:
mem_ctx the memory context that the duplicated value will be allocated from
v the ldb_val to be duplicated.
Returns:
the duplicated ldb_val structure.

Definition at line 96 of file ldb_msg.c.

References ldb_val::data, and ldb_val::length.

{
      struct ldb_val v2;
      v2.length = v->length;
      if (v->data == NULL) {
            v2.data = NULL;
            return v2;
      }

      /* the +1 is to cope with buggy C library routines like strndup
         that look one byte beyond */
      v2.data = talloc_array(mem_ctx, uint8_t, v->length+1);
      if (!v2.data) {
            v2.length = 0;
            return v2;
      }

      memcpy(v2.data, v->data, v->length);
      ((char *)v2.data)[v->length] = 0;
      return v2;
}


Generated by  Doxygen 1.6.0   Back to index