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

struct nl_data* nl_data_alloc ( void *  buf,
size_t  size 
) [read]

Allocate a new abstract data object.

  • buf Data buffer containing the actual data.
  • size Size of data buffer.
Allocates a new abstract data and copies the specified data buffer into the new handle.

Returns:
Newly allocated data handle or NULL

Definition at line 38 of file data.c.

Referenced by nl_data_alloc_attr(), and nl_data_clone().

{
      struct nl_data *data;

      data = calloc(1, sizeof(*data));
      if (!data)
            goto errout;

      data->d_data = calloc(1, size);
      if (!data->d_data) {
            free(data);
            goto errout;
      }

      data->d_size = size;

      if (buf)
            memcpy(data->d_data, buf, size);

      return data;
errout:
      return NULL;
}


Generated by  Doxygen 1.6.0   Back to index