static struct mem_stream *create_mem_stream_internal(uint64_t size)
{
- struct mem_stream *m = kmalloc(sizeof(struct mem_stream),GFP_KERNEL);
+ struct mem_stream *m = palacios_alloc(sizeof(struct mem_stream));
if (!m) {
return 0;
m->data = vmalloc(size);
if (!m->data) {
- kfree(m);
+ palacios_free(m);
return 0;
}
{
if (m) {
if (m->data) {
- kfree(m->data);
+ vfree(m->data);
}
m->data=0;
- kfree(m);
+ palacios_free(m);
}
}
memcpy(data,m->data,nc);
- kfree(m->data);
+ vfree(m->data);
m->data=data;
m->size=new_size;
if (!mks) {
char *mykey;
- mykey = kmalloc(strlen(url+4)+1,GFP_KERNEL);
+ mykey = palacios_alloc(strlen(url+4)+1);
if (!mykey) {
ERROR("cannot allocate space for new in-memory keyed stream %s\n",url);
strcpy(mykey,url+4);
- mks = (struct mem_keyed_stream *) kmalloc(sizeof(struct mem_keyed_stream),GFP_KERNEL);
+ mks = (struct mem_keyed_stream *) palacios_alloc(sizeof(struct mem_keyed_stream));
if (!mks) {
- kfree(mykey);
+ palacios_free(mykey);
ERROR("cannot allocate in-memory keyed stream %s\n",url);
return 0;
}
mks->ht = (void*) palacios_create_htable(DEF_NUM_KEYS,hash_func,hash_comp);
if (!mks->ht) {
- kfree(mks);
- kfree(mykey);
+ palacios_free(mks);
+ palacios_free(mykey);
ERROR("cannot allocate in-memory keyed stream %s\n",url);
return 0;
}
if (!palacios_htable_insert(mem_streams,(addr_t)(mykey),(addr_t)mks)) {
palacios_free_htable(mks->ht,1,1);
- kfree(mks);
- kfree(mykey);
+ palacios_free(mks);
+ palacios_free(mykey);
ERROR("cannot insert in-memory keyed stream %s\n",url);
return 0;
}
m = (struct mem_stream *) palacios_htable_search(s,(addr_t)key);
if (!m) {
- char *mykey = kmalloc(strlen(key)+1,GFP_KERNEL);
+ char *mykey = palacios_alloc(strlen(key)+1);
if (!mykey) {
ERROR("cannot allocate copy of key for key %s\n",key);
m = create_mem_stream();
if (!m) {
- kfree(mykey);
+ palacios_free(mykey);
ERROR("cannot allocate mem keyed stream for key %s\n",key);
return 0;
}
if (!palacios_htable_insert(s,(addr_t)mykey,(addr_t)m)) {
destroy_mem_stream(m);
- kfree(mykey);
+ palacios_free(mykey);
ERROR("cannot insert mem keyed stream for key %s\n",key);
return 0;
}
if (!m) {
char *mykey;
- mykey=kmalloc(strlen(key)+1,GFP_KERNEL);
+ mykey=palacios_alloc(strlen(key)+1);
if (!mykey) {
ERROR("cannot allocate key space for preallocte for key %s\n",key);
return 0;
}
- fks = kmalloc(sizeof(struct file_keyed_stream),GFP_KERNEL);
+ fks = palacios_alloc(sizeof(struct file_keyed_stream));
if (!fks) {
ERROR("cannot allocate space for file stream\n");
return 0;
}
- fks->path = (char*)kmalloc(strlen(url+5)+1,GFP_KERNEL);
+ fks->path = (char*)palacios_alloc(strlen(url+5)+1);
if (!(fks->path)) {
ERROR("cannot allocate space for file stream\n");
- kfree(fks);
+ palacios_free(fks);
return 0;
}
fail_out:
- kfree(fks->path);
- kfree(fks);
+ palacios_free(fks->path);
+ palacios_free(fks);
return 0;
}
{
struct file_keyed_stream *fks = (struct file_keyed_stream *) stream;
- kfree(fks->path);
- kfree(fks);
+ palacios_free(fks->path);
+ palacios_free(fks);
}
// the path is the stream's path plus the key name
// file:/home/foo + "regext" => "/home/foo/regext"
- path = (char *) kmalloc(strlen(fks->path)+strlen(key)+2,GFP_KERNEL);
+ path = (char *) palacios_alloc(strlen(fks->path)+strlen(key)+2);
if (!path) {
ERROR("cannot allocate file keyed stream for key %s\n",key);
return 0;
strcat(path,"/");
strcat(path,key);
- fs = (struct file_stream *) kmalloc(sizeof(struct file_stream *),GFP_KERNEL);
+ fs = (struct file_stream *) palacios_alloc(sizeof(struct file_stream *));
if (!fs) {
ERROR("cannot allocate file keyed stream for key %s\n",key);
- kfree(path);
+ palacios_free(path);
return 0;
}
if (IS_ERR(fs->f)) {
ERROR("cannot open relevent file \"%s\" for stream \"file:%s\" and key \"%s\"\n",path,fks->path,key);
- kfree(fs);
- kfree(path);
+ palacios_free(fs);
+ palacios_free(path);
return 0;
}
- kfree(path);
+ palacios_free(path);
return fs;
}
filp_close(fs->f,NULL);
- kfree(fs);
+ palacios_free(fs);
}
static sint64_t write_key_file(v3_keyed_stream_t stream,
struct palacios_user_keyed_stream_op *new;
if (!old) {
- new = kmalloc(sizeof(struct palacios_user_keyed_stream_op)+buf_len,GFP_ATOMIC);
+ new = palacios_alloc(sizeof(struct palacios_user_keyed_stream_op)+buf_len);
if (!new) {
return -1;
} else {
old->buf_len=buf_len;
return 0;
} else {
- kfree(old);
+ palacios_free(old);
*op = 0 ;
return resize_op(op,buf_len);
}
spin_unlock_irqrestore(&(s->lock), f2);
spin_unlock_irqrestore(&(user_streams->lock), f1);
- kfree(s->url);
- kfree(s);
+ palacios_free(s->url);
+ palacios_free(s);
return 0;
}
return -1;
}
- url = kmalloc(len,GFP_KERNEL);
+ url = palacios_alloc(len);
if (!url) {
ERROR("cannot allocate url for user keyed stream\n");
list_for_each_entry(s, &(user_streams->streams), node) {
if (!strncasecmp(url, s->url, len)) {
ERROR("user keyed stream connection with url \"%s\" already exists\n", url);
- kfree(url);
+ palacios_free(url);
return -1;
}
}
spin_unlock_irqrestore(&(user_streams->lock), flags);
// Create connection
- s = kmalloc(sizeof(struct user_keyed_stream), GFP_KERNEL);
+ s = palacios_alloc(sizeof(struct user_keyed_stream));
if (!s) {
ERROR("cannot allocate new user keyed stream for %s\n",url);
- kfree(url);
+ palacios_free(url);
return -1;
}
if (fd < 0) {
ERROR("cannot allocate file descriptor for new user keyed stream for %s\n",url);
- kfree(s);
- kfree(url);
+ palacios_free(s);
+ palacios_free(url);
return -1;
}
{
struct net_stream * ns = NULL;
- ns = kmalloc(sizeof(struct net_stream), GFP_KERNEL);
+ ns = palacios_alloc(sizeof(struct net_stream));
if (!ns) {
ERROR("Cannot allocate a net_stream\n");
if (ns) {
ns->sock->ops->release(ns->sock);
- kfree(ns);
+ palacios_free(ns);
ERROR("Close Socket\n");
}
- kfree(ns);
+ palacios_free(ns);
}
}
// close the accept socket
accept_sock->ops->release(accept_sock);
- kfree(accept_sock);
+ palacios_free(accept_sock);
return ns;
}
int ip_len;
int port_len;
- nks = kmalloc(sizeof(struct net_keyed_stream),GFP_KERNEL);
+ nks = palacios_alloc(sizeof(struct net_keyed_stream));
if (!nks) {
ERROR("Could not allocate space in open_stream_net\n");
if (!(nks->ns)) {
ERROR("Could not create network stream\n");
- kfree(nks);
+ palacios_free(nks);
return 0;
}
connect_to_ip(nks->ns,host_ip, host_port);
} else {
ERROR("Mode not recognized\n");
- kfree(nks);
+ palacios_free(nks);
return NULL;
}
return -1;
}
- user_streams = kmalloc(sizeof(struct user_keyed_streams),GFP_KERNEL);
+ user_streams = palacios_alloc(sizeof(struct user_keyed_streams));
if (!user_streams) {
ERROR("failed to allocated list for user streams\n");
{
palacios_free_htable(mem_streams,1,1);
- kfree(user_streams);
+ palacios_free(user_streams);
WARNING("Deinit of Palacios Keyed Streams likely leaked memory\n");