summaryrefslogtreecommitdiffstats
path: root/vppapigen
AgeCommit message (Expand)AuthorFilesLines
2016-12-02API: Packaging of JSON files.Ole Troan2-292/+1
2016-11-23Fix coverity warnings, VPP-486Dave Barach1-0/+1
2016-11-21Add client-side msg_name_and_crc -> msg_index tableDave Barach4-37/+219
2016-11-15Dump routes (VPP-500)Steven1-0/+2
2016-10-26python api - vla - allow the user to pass in a normal python listGabriel Ganne1-2/+11
2016-10-12VPP-362 Implement dumping of LISP adjacenciesFilip Tehlar1-0/+2
2016-09-30VPP-120: include custom types to Python representation of vpe.apiMarek Gradzki2-20/+42
2016-09-21vpp python api - fix vla pack generationGabriel Ganne1-20/+15
2016-09-13Python API: Re-adding rudimentary variable length array pack support.Ole Troan1-7/+19
2016-08-25VPP Python language binding - plugin supportOle Troan4-2/+283
2016-08-05vpp-189 Clean up more coverity warningsDave Barach2-28/+31
2016-07-22VPP-189 Fix 137 coverity no-op issues from vpeapigenChris Luke1-2/+12
2016-07-21VPP-123: remove japi (the old Java API)Marek Gradzki4-837/+10
2016-07-08Remove unnecessary and obsolete configure.ac directivesDamjan Marion1-1/+1
2016-06-27More janitorial workDave Barach1-5/+5
2016-06-24VPP-118: add support for variable length arrays to jvppMarek Gradzki3-2/+24
2016-04-21Fix warning in vppapigenDamjan Marion1-1/+1
2016-04-20Python-API: Inital commit of Python bindings for the VPP API.Ole Troan3-4/+89
2016-04-18Add support for AArch32Christophe Fontaine1-2/+2
2016-03-14lex - yylval undeclaredVincent JARDIN1-0/+1
2016-02-01Refactor vpp-japiRobert Varga1-46/+72
2015-12-23ylwrap is also autotools autogenerated fileDamjan Marion1-247/+0
2015-12-15Remove autotools generated productsDave Barach7-8613/+0
2015-12-08Initial commit of vpp code.v1.0.0Ed Warnicke15-0/+12200
) 2001, 2002, 2003 Eliot Dresselhaus Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <vppinfra/vec.h> #include <vppinfra/mem.h> /* Vector resize operator. Called as needed by various macros such as vec_add1() when we need to allocate memory. */ void * vec_resize_allocate_memory (void *v, word length_increment, uword data_bytes, uword header_bytes, uword data_align) { vec_header_t *vh = _vec_find (v); uword old_alloc_bytes, new_alloc_bytes; void *old, *new; header_bytes = vec_header_bytes (header_bytes); data_bytes += header_bytes; if (!v) { new = clib_mem_alloc_aligned_at_offset (data_bytes, data_align, header_bytes, 1 /* yes, call os_out_of_memory */ ); data_bytes = clib_mem_size (new); memset (new, 0, data_bytes); v = new + header_bytes; _vec_len (v) = length_increment; return v; } vh->len += length_increment; old = v - header_bytes; /* Vector header must start heap object. */ ASSERT (clib_mem_is_heap_object (old)); old_alloc_bytes = clib_mem_size (old); /* Need to resize? */ if (data_bytes <= old_alloc_bytes) return v; new_alloc_bytes = (old_alloc_bytes * 3) / 2; if (new_alloc_bytes < data_bytes) new_alloc_bytes = data_bytes; new = clib_mem_alloc_aligned_at_offset (new_alloc_bytes, data_align, header_bytes, 1 /* yes, call os_out_of_memory */ ); /* FIXME fail gracefully. */ if (!new) clib_panic ("vec_resize fails, length increment %d, data bytes %d, alignment %d", length_increment, data_bytes, data_align); clib_memcpy (new, old, old_alloc_bytes); clib_mem_free (old); v = new; /* Allocator may give a bit of extra room. */ new_alloc_bytes = clib_mem_size (v); /* Zero new memory. */ memset (v + old_alloc_bytes, 0, new_alloc_bytes - old_alloc_bytes); return v + header_bytes; } uword clib_mem_is_vec_h (void *v, uword header_bytes) { return clib_mem_is_heap_object (vec_header (v, header_bytes)); } /** \cond */ #ifdef TEST #include <stdio.h> void main (int argc, char *argv[]) { word n = atoi (argv[1]); word i, *x = 0; typedef struct { word x, y, z; } FOO; FOO *foos = vec_init (FOO, 10), *f; vec_validate (foos, 100); foos[100].x = 99; _vec_len (foos) = 0; for (i = 0; i < n; i++) { vec_add1 (x, i); vec_add2 (foos, f, 1); f->x = 2 * i; f->y = 3 * i; f->z = 4 * i; } { word n = 2; word m = 42; vec_delete (foos, n, m); } { word n = 2; word m = 42; vec_insert (foos, n, m); } vec_free (x); vec_free (foos); exit (0); } #endif /** \endcond */ /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */