static HashTable* make_persistent_sdl_function_headers(HashTable *headers, HashTable *ptr_map)
{
	HashTable *pheaders;
	sdlSoapBindingFunctionHeaderPtr tmp, pheader;
	encodePtr penc;
	sdlTypePtr ptype;
	zend_string *key;

	pheaders = malloc(sizeof(HashTable));
	zend_hash_init(pheaders, zend_hash_num_elements(headers), NULL, delete_header_persistent, 1);

	ZEND_HASH_FOREACH_STR_KEY_PTR(headers, key, tmp) {
		pheader = malloc(sizeof(sdlSoapBindingFunctionHeader));
		memset(pheader, 0, sizeof(sdlSoapBindingFunctionHeader));
		*pheader = *tmp;

		if (pheader->name) {
			pheader->name = strdup(pheader->name);
		}
		if (pheader->ns) {
			pheader->ns = strdup(pheader->ns);
		}

		if (pheader->encode && pheader->encode->details.sdl_type) {
			if ((penc = zend_hash_str_find_ptr(ptr_map, (char*)&pheader->encode, sizeof(encodePtr))) == NULL) {
				assert(0);
			}
			pheader->encode = penc;
		}
		if (pheader->element) {
			if ((ptype = zend_hash_str_find_ptr(ptr_map, (char*)&pheader->element, sizeof(sdlTypePtr))) == NULL) {
				assert(0);
			}
			pheader->element = ptype;
		}

		if (pheader->headerfaults) {
			pheader->headerfaults = make_persistent_sdl_function_headers(pheader->headerfaults, ptr_map);
		}

		if (key) {
			/* We have to duplicate key emalloc->malloc */
			zend_hash_str_add_ptr(pheaders, ZSTR_VAL(key), ZSTR_LEN(key), pheader);
		} else {
			zend_hash_next_index_insert_ptr(pheaders, pheader);
		}
	} ZEND_HASH_FOREACH_END();

	return pheaders;
}
static HashTable* make_persistent_sdl_function_headers(HashTable *headers, HashTable *ptr_map)
{
	HashTable *pheaders;
	sdlSoapBindingFunctionHeaderPtr tmp, pheader;
	encodePtr penc;
	sdlTypePtr ptype;
	zend_string *key;

	pheaders = malloc(sizeof(HashTable));
	zend_hash_init(pheaders, zend_hash_num_elements(headers), NULL, delete_header_persistent, 1);

	ZEND_HASH_FOREACH_STR_KEY_PTR(headers, key, tmp) {
		pheader = malloc(sizeof(sdlSoapBindingFunctionHeader));
		memset(pheader, 0, sizeof(sdlSoapBindingFunctionHeader));
		*pheader = *tmp;

		if (pheader->name) {
			pheader->name = strdup(pheader->name);
		}
		if (pheader->ns) {
			pheader->ns = strdup(pheader->ns);
		}

		if (pheader->encode && pheader->encode->details.sdl_type) {
			if ((penc = zend_hash_str_find_ptr(ptr_map, (char*)&pheader->encode, sizeof(encodePtr))) == NULL) {
				assert(0);
			}
			pheader->encode = penc;
		}
		if (pheader->element) {
			if ((ptype = zend_hash_str_find_ptr(ptr_map, (char*)&pheader->element, sizeof(sdlTypePtr))) == NULL) {
				assert(0);
			}
			pheader->element = ptype;
		}

		if (pheader->headerfaults) {
			pheader->headerfaults = make_persistent_sdl_function_headers(pheader->headerfaults, ptr_map);
		}

		if (key) {
			 
			zend_hash_str_add_ptr(pheaders, ZSTR_VAL(key), ZSTR_LEN(key), pheader);
		} else {
			zend_hash_next_index_insert_ptr(pheaders, pheader);
		}
	} ZEND_HASH_FOREACH_END();

	return pheaders;
}