static sdlContentModelPtr make_persistent_sdl_model(sdlContentModelPtr model, HashTable *ptr_map, HashTable *bp_types, HashTable *bp_encoders)
{
	sdlContentModelPtr pmodel;
	sdlContentModelPtr tmp, pcontent;

	pmodel = malloc(sizeof(sdlContentModel));
	memset(pmodel, 0, sizeof(sdlContentModel));
	*pmodel = *model;

	switch (pmodel->kind) {
		case XSD_CONTENT_ELEMENT:
			if (pmodel->u.element) {
				make_persistent_sdl_type_ref(&pmodel->u.element, ptr_map, bp_types);
			}
			break;

		case XSD_CONTENT_SEQUENCE:
		case XSD_CONTENT_ALL:
		case XSD_CONTENT_CHOICE:
			pmodel->u.content = malloc(sizeof(HashTable));
			zend_hash_init(pmodel->u.content, zend_hash_num_elements(model->u.content), NULL, delete_model_persistent, 1);

			ZEND_HASH_FOREACH_PTR(model->u.content, tmp) {
				pcontent = make_persistent_sdl_model(tmp, ptr_map, bp_types, bp_encoders);
				zend_hash_next_index_insert_ptr(pmodel->u.content, pcontent);
			} ZEND_HASH_FOREACH_END();
			break;

		case XSD_CONTENT_GROUP_REF:
			if (pmodel->u.group_ref) {
				pmodel->u.group_ref = strdup(pmodel->u.group_ref);
			}
			break;

		case XSD_CONTENT_GROUP:
			if (pmodel->u.group) {
				make_persistent_sdl_type_ref(&pmodel->u.group, ptr_map, bp_types);
			}
			break;

		default:
			break;
	}

	return pmodel;
}
static sdlContentModelPtr make_persistent_sdl_model(sdlContentModelPtr model, HashTable *ptr_map, HashTable *bp_types, HashTable *bp_encoders)
{
	sdlContentModelPtr pmodel;
	sdlContentModelPtr tmp, pcontent;

	pmodel = malloc(sizeof(sdlContentModel));
	memset(pmodel, 0, sizeof(sdlContentModel));
	*pmodel = *model;

	switch (pmodel->kind) {
		case XSD_CONTENT_ELEMENT:
			if (pmodel->u.element) {
				make_persistent_sdl_type_ref(&pmodel->u.element, ptr_map, bp_types);
			}
			break;

		case XSD_CONTENT_SEQUENCE:
		case XSD_CONTENT_ALL:
		case XSD_CONTENT_CHOICE:
			pmodel->u.content = malloc(sizeof(HashTable));
			zend_hash_init(pmodel->u.content, zend_hash_num_elements(model->u.content), NULL, delete_model_persistent, 1);

			ZEND_HASH_FOREACH_PTR(model->u.content, tmp) {
				pcontent = make_persistent_sdl_model(tmp, ptr_map, bp_types, bp_encoders);
				zend_hash_next_index_insert_ptr(pmodel->u.content, pcontent);
			} ZEND_HASH_FOREACH_END();
			break;

		case XSD_CONTENT_GROUP_REF:
			if (pmodel->u.group_ref) {
				pmodel->u.group_ref = strdup(pmodel->u.group_ref);
			}
			break;

		case XSD_CONTENT_GROUP:
			if (pmodel->u.group) {
				make_persistent_sdl_type_ref(&pmodel->u.group, ptr_map, bp_types);
			}
			break;

		default:
			break;
	}

	return pmodel;
}