Beispiel #1
0
struct http_route *
http_route_new(void) {
    struct http_route *route;

    route = c_malloc0(sizeof(struct http_route));

    return route;
}
Beispiel #2
0
struct http_url *
http_url_new(void) {
    struct http_url *url;

    url = c_malloc0(sizeof(struct http_url));

    return url;
}
Beispiel #3
0
struct http_router *
http_router_new(void) {
    struct http_router *router;

    router = c_malloc0(sizeof(struct http_router));

    router->routes = c_ptr_vector_new();

    return router;
}
Beispiel #4
0
struct http_response *
http_response_new(void) {
    struct http_response *response;

    response = c_malloc0(sizeof(struct http_response));

    response->version = HTTP_1_1;
    response->headers = http_headers_new();

    return response;
}
Beispiel #5
0
/* For reference: There was some deliberation over whether to have a
 * constructor that could throw an exception but looking at standard
 * practices with several high level OO languages including python, C++,
 * C# Java and Ruby they all support exceptions in constructors and the
 * general consensus appears to be that throwing an exception is neater
 * than successfully constructing with an internal error status that
 * would then have to be explicitly checked via some form of ::is_ok()
 * method.
 */
cg_device_t *
cg_device_new(void)
{
    cg_device_t *dev;

    _cg_init();

#ifdef ENABLE_PROFILE
    /* We need to be absolutely sure that uprof has been initialized
     * before calling _cg_uprof_init. uprof_init (NULL, NULL)
     * will be a NOP if it has been initialized but it will also
     * mean subsequent parsing of the UProf GOptionGroup will have no
     * affect.
     *
     * Sadly GOptionGroup based library initialization is extremely
     * fragile by design because GOptionGroups have no notion of
     * dependencies and so the order things are initialized isn't
     * currently under tight control.
     */
    uprof_init(NULL, NULL);
    _cg_uprof_init();
#endif

    dev = c_malloc0(sizeof(cg_device_t));
    memset(dev, 0, sizeof(cg_device_t));

    /* Convert the context into an object immediately in case any of the
       code below wants to verify that the context pointer is a valid
       object */
    _cg_device_object_new(dev);

    /* TODO: remove final uses of _CG_GET_DEVICE() which depends on
     * having one globally accessible device pointer. */
    _cg_device = dev;

    /* Init default values */
    memset(dev->features, 0, sizeof(dev->features));
    memset(dev->private_features, 0, sizeof(dev->private_features));

    dev->rectangle_state = CG_WINSYS_RECTANGLE_STATE_UNKNOWN;

    memset(dev->winsys_features, 0, sizeof(dev->winsys_features));

    return dev;
}