2 Copyright (C) 2012 Modelon AB
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the BSD style license.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 FMILIB_License.txt file for more details.
12 You should have received a copy of the FMILIB_License.txt file
13 along with this program. If not, contact Modelon AB <http://www.modelon.com>.
17 #include "JM/jm_callbacks.h"
18 #include "JM/jm_named_ptr.h"
20 jm_named_ptr jm_named_alloc(const char* name, size_t size, size_t nameoffset, jm_callbacks* c) {
22 size_t namelen = strlen(name);
23 size_t sizefull = size + namelen;
24 out.ptr = c->malloc(sizefull);
29 outname += nameoffset;
31 memcpy(outname, name, namelen);
38 jm_named_ptr jm_named_alloc_v(jm_vector(char)* name, size_t size, size_t nameoffset, jm_callbacks* c) {
40 size_t namelen = jm_vector_get_size(char)(name);
41 size_t sizefull = size + namelen;
42 out.ptr = c->malloc(sizefull);
45 char * outname = out.ptr;
46 outname += nameoffset;
48 memcpy(outname, jm_vector_get_itemp(char)(name,0), namelen);
55 #define JM_TEMPLATE_INSTANCE_TYPE jm_named_ptr
56 #include "JM/jm_vector_template.h"