J2KAPI(j2k_Component*) j2k_Component_construct(nrt_Uint32 width, nrt_Uint32 height, nrt_Uint32 precision, NRT_BOOL isSigned, nrt_Uint32 offsetX, nrt_Uint32 offsetY, nrt_Uint32 separationX, nrt_Uint32 separationY, nrt_Error *error) { j2k_Component *component = NULL; ComponentImpl *impl = NULL; component = (j2k_Component*) J2K_MALLOC(sizeof(j2k_Component)); if (!component) { nrt_Error_init(error, NRT_STRERROR(NRT_ERRNO), NRT_CTXT, NRT_ERR_MEMORY); goto CATCH_ERROR; } memset(component, 0, sizeof(j2k_Component)); /* create the Component interface */ impl = (ComponentImpl *) J2K_MALLOC(sizeof(ComponentImpl)); if (!impl) { nrt_Error_init(error, NRT_STRERROR(NRT_ERRNO), NRT_CTXT, NRT_ERR_MEMORY); goto CATCH_ERROR; } memset(impl, 0, sizeof(ComponentImpl)); component->data = impl; component->iface = &ComponentInterface; impl->width = width; impl->height = height; impl->precision = precision; impl->isSigned = isSigned; impl->x0 = offsetX; impl->y0 = offsetY; impl->xSeparation = separationX; impl->ySeparation = separationY; return component; CATCH_ERROR: { if (component) { j2k_Component_destruct(&component); } return NULL; } }
Container_destruct(J2K_USER_DATA * data) { if (data) { ContainerImpl *impl = (ContainerImpl*) data; if (impl->components) { nrt_Uint32 i = 0; for(; i < impl->nComponents; ++i) { j2k_Component *c = impl->components[i]; if (c) j2k_Component_destruct(&c); } impl->components = NULL; } J2K_FREE(data); } }