summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
2c714a0)
Having the constructor in the vppapiclient library led to
conflicts with applications wanting to allocate their own heap.
Note: Change of behaviour, applications that do not use a CLIB
heap must now call vac_mem_init() before using any functions from
vppapiclient.
Type: fix
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: Ib155a54579ea5a0dbc26cb4b6daca1274e1dfdfa
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
bool rx_is_running = false;
bool timeout_thread_cancelled = false;
bool rx_is_running = false;
bool timeout_thread_cancelled = false;
-/* Set to true to enable memory tracing */
-bool mem_trace = false;
-
-__attribute__((constructor))
-static void
-vac_client_constructor (void)
-{
- clib_mem_init (0, 1 << 30);
- if (mem_trace)
- clib_mem_trace (1);
-}
-
-__attribute__((destructor))
-static void
-vac_client_destructor (void)
-{
- if (mem_trace)
- fformat(stderr, "TRACE: %s",
- format (0, "%U\n",
- format_mheap, clib_mem_get_heap (), 1));
-}
-
-
static void
init (void)
{
static void
init (void)
{
int
vac_connect (char * name, char * chroot_prefix, vac_callback_t cb,
int
vac_connect (char * name, char * chroot_prefix, vac_callback_t cb,
{
rx_thread_done = false;
int rv = 0;
vac_main_t *pm = &vac_main;
{
rx_thread_done = false;
int rv = 0;
vac_main_t *pm = &vac_main;
+ assert (clib_mem_get_heap ());
init();
if (chroot_prefix != NULL)
vl_set_memory_root_path (chroot_prefix);
init();
if (chroot_prefix != NULL)
vl_set_memory_root_path (chroot_prefix);
void
vac_set_error_handler (vac_error_callback_t cb)
{
void
vac_set_error_handler (vac_error_callback_t cb)
{
+ assert (clib_mem_get_heap ());
if (cb) clib_error_register_handler (cb, 0);
}
if (cb) clib_error_register_handler (cb, 0);
}
+
+/*
+ * Required if application doesn't use a VPP heap.
+ */
+void
+vac_mem_init (size_t size)
+{
+ if (size == 0)
+ clib_mem_init (0, 1 << 30); // default
+ else
+ clib_mem_init (0, size);
+}
#define included_vppapiclient_h
#include <stdint.h>
#define included_vppapiclient_h
#include <stdint.h>
typedef void (*vac_callback_t)(unsigned char * data, int len);
typedef void (*vac_error_callback_t)(void *, unsigned char *, int);
typedef void (*vac_callback_t)(unsigned char * data, int len);
typedef void (*vac_error_callback_t)(void *, unsigned char *, int);
void vac_rx_suspend (void);
void vac_rx_resume (void);
void vac_set_error_handler(vac_error_callback_t);
void vac_rx_suspend (void);
void vac_rx_resume (void);
void vac_set_error_handler(vac_error_callback_t);
+void vac_mem_init (size_t size);
+
void vac_rx_suspend (void);
void vac_rx_resume (void);
void vac_set_error_handler(vac_error_callback_t);
void vac_rx_suspend (void);
void vac_rx_resume (void);
void vac_set_error_handler(vac_error_callback_t);
+void vac_mem_init (size_t size);
+""")
global vpp_object
vpp_object = parent
global vpp_object
vpp_object = parent
+ vpp_api.vac_mem_init(0);
+
# Register error handler
vpp_api.vac_set_error_handler(vac_error_handler)
# Register error handler
vpp_api.vac_set_error_handler(vac_error_handler)