#include "FIDIndex.h" #include #include #include /** * Creates a new FIDIndex such that: * * - FID equals the ID parameter * - occuranceOffset equals the offset parameter * */ FIDIndex *FIDIndex_create(char *ID, uint32_t offset) { FIDIndex *idx = calloc(1, sizeof(FIDIndex)); idx->FID = calloc(strlen(ID) + 1, sizeof(char)); strcpy(idx->FID, ID); idx->occuranceOffset = offset; return idx; } /** * Allows two FIDIndex structs to be compared * in order to be sorted within the arrayList implimentation * * left and right are pointers to FIDIndex structs * * Returns <0 if left FID is greater than right FID, * >0 in the converse, and 0 if both FID's are equal */ int compareFIDIndex(const void *left, const void *right) { const FIDIndex *pLeft = (FIDIndex *)(left), *pRight = (FIDIndex *)(right); return (strcmp(pLeft->FID, pRight->FID)); } /** * Frees the specified FIDIndex */ void cleanFID(void *const idx) { free(((FIDIndex *)(idx))->FID); }