/* * generic arrays */ #include #include #include /** * snd_array_new - get a new element from the given array * @array: the array object * * Get a new element from the given array. If it exceeds the * pre-allocated array size, re-allocate the array. * * Returns NULL if allocation failed. */ void *snd_array_new(struct snd_array *array) { if (snd_BUG_ON(!array->elem_size)) return NULL; if (array->used >= array->alloced) { int num = array->alloced + array->alloc_align; int oldsize = array->alloced * array->elem_size; int size = (num + 1) * array->elem_size; void *nlist; if (snd_BUG_ON(num >= 4096)) return NULL; nlist = krealloc(array->list, size, GFP_KERNEL); if (!nlist) return NULL; memset(nlist + oldsize, 0, size - oldsize); array->list = nlist; array->alloced = num; } return snd_array_elem(array, array->used++); } EXPORT_SYMBOL_GPL(snd_array_new); /** * snd_array_free - free the given array elements * @array: the array object */ void snd_array_free(struct snd_array *array) { kfree(array->list); array->used = 0; array->alloced = 0; array->list = NULL; } EXPORT_SYMBOL_GPL(snd_array_free); '>nds-private-remove net-next plumbingsTobias Klauser
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBhumika Goyal <bhumirks@gmail.com>2017-01-25 00:54:07 +0530
committerDan Williams <dan.j.williams@intel.com>2017-01-31 18:16:30 -0800
commit970d14e3989160ee9e97c7d75ecbc893fd29dab9 (patch)
tree4a731cac4efedb17f86a912ec56c151d26792abe /tools/arch/microblaze
parent7a308bb3016f57e5be11a677d15b821536419d36 (diff)
nvdimm: constify device_type structures
Declare device_type structure as const as it is only stored in the type field of a device structure. This field is of type const, so add const to declaration of device_type structure. File size before: text data bss dec hex filename 19278 3199 16 22493 57dd nvdimm/namespace_devs.o File size after: text data bss dec hex filename 19929 3160 16 23105 5a41 nvdimm/namespace_devs.o Signed-off-by: Bhumika Goyal <bhumirks@gmail.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'tools/arch/microblaze')