Beispiel #1
0
int main(int argc,char *argv[])
{
	struct freemap *fm;
	int fd;
	off_t offset;
	unsigned int size;
	FILE *f;
	struct freemap *newfm;

	fm = freemap_new();
	if(fm == NULL)
		return -1;
	if(freemap_add(fm,NULL,FREEMAP_CREAT) != 0)
		return -1;
	size = 4096;
	if(freemap_malloc(fm,&size,&fd,&offset) != 0)
		return -1;

	f = fopen("test","w+");
	if(freemap_dump(fm,f) != 0)
		return -1;
	if(fseek(f,SEEK_SET,0L) != 0)
		return -1;
	newfm = freemap_load(f);
	if(newfm == NULL)
		return -1;
	freemap_free(fm);
	freemap_free(newfm);
	return 0;
}
Beispiel #2
0
void *mdb_handle_delete(mdb_handle_map_t *hmap, mdb_handle_t h)
{
    uint32_t  useid = HANDLE_USEID(h);
    int       index = HANDLE_INDEX(h);
    void     *old_data;

    MDB_CHECKARG(hmap && h != MDB_HANDLE_INVALID, NULL);


    if (!(old_data = index_free(&hmap->indextbl, useid,index))) {
        /* errno has been set by index_free() */
        return NULL;
    }

    if (freemap_free(&hmap->freemap, index) < 0) {
        /* errno has been set by freemap_free() */
        return NULL;
    }

    return old_data;
}