Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Do not mark all public function as potentially inline since it breaks on mac (get...
[simgrid.git] / src / include / surf / surf_resource.h
1
2 /* Copyright (c) 2009 The SimGrid Team. All rights reserved.                */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "surf/surf.h"
8 #ifndef SURF_RESOURCE_H
9 #define SURF_RESOURCE_H
10
11 static XBT_INLINE
12 surf_resource_t surf_resource_new(size_t childsize,
13     surf_model_t model, char *name, xbt_dict_t props) {
14   surf_resource_t res = xbt_malloc0(childsize);
15   res->model = model;
16   res->name = name;
17   res->properties = props;
18   return res;
19 }
20
21 static XBT_INLINE void surf_resource_free(void* r) {
22   surf_resource_t resource = r;
23   if (resource->name)
24     free(resource->name);
25   if (resource->properties)
26     xbt_dict_free(&resource->properties);
27   free(resource);
28 }
29
30 static XBT_INLINE const char *surf_resource_name(const void *resource) {
31   return ((surf_resource_t)resource)->name;
32 }
33
34 static XBT_INLINE xbt_dict_t surf_resource_properties(const void *resource) {
35   return ((surf_resource_t)resource)->properties;
36 }
37
38 #endif /* SURF_RESOURCE_H */