Lines Matching full:data

2  * lib/data.c		Abstract Data
14 * @defgroup data Abstract Data
29 * Allocate a new abstract data object.
30 * @arg buf Data buffer containing the actual data.
31 * @arg size Size of data buffer.
33 * Allocates a new abstract data and copies the specified data
36 * @return Newly allocated data handle or NULL
40 struct nl_data *data; in nl_data_alloc() local
42 data = calloc(1, sizeof(*data)); in nl_data_alloc()
43 if (!data) in nl_data_alloc()
46 data->d_data = calloc(1, size); in nl_data_alloc()
47 if (!data->d_data) { in nl_data_alloc()
48 free(data); in nl_data_alloc()
52 data->d_size = size; in nl_data_alloc()
55 memcpy(data->d_data, buf, size); in nl_data_alloc()
57 return data; in nl_data_alloc()
63 * Allocate abstract data object based on netlink attribute.
66 * Allocates a new abstract data and copies the payload of the
67 * attribute to the abstract data object.
70 * @return Newly allocated data handle or NULL
78 * Clone an abstract data object.
79 * @arg src Abstract data object
89 * Append data to an abstract data object.
90 * @arg data Abstract data object.
91 * @arg buf Data buffer containing the data to be appended.
92 * @arg size Size of data to be apppended.
94 * Reallocates an abstract data and copies the specified data
99 int nl_data_append(struct nl_data *data, void *buf, size_t size) in nl_data_append() argument
105 data->d_data = realloc(data->d_data, data->d_size + size); in nl_data_append()
106 if (!data->d_data) in nl_data_append()
110 memcpy(data->d_data + data->d_size, buf, size); in nl_data_append()
112 memset(data->d_data + data->d_size, 0, size); in nl_data_append()
114 data->d_size += size; in nl_data_append()
121 * Free an abstract data object.
122 * @arg data Abstract data object.
124 void nl_data_free(struct nl_data *data) in nl_data_free() argument
126 if (data) in nl_data_free()
127 free(data->d_data); in nl_data_free()
129 free(data); in nl_data_free()
140 * Get data buffer of abstract data object.
141 * @arg data Abstract data object.
142 * @return Data buffer or NULL if empty.
144 void *nl_data_get(struct nl_data *data) in nl_data_get() argument
146 return data->d_size > 0 ? data->d_data : NULL; in nl_data_get()
150 * Get size of data buffer of abstract data object.
151 * @arg data Abstract data object.
152 * @return Size of data buffer.
154 size_t nl_data_get_size(struct nl_data *data) in nl_data_get_size() argument
156 return data->d_size; in nl_data_get_size()
167 * Compare two abstract data objects.
168 * @arg a Abstract data object.
169 * @arg b Another abstract data object.