static void freeScheme(Scheme* scheme) { if(scheme != NULL) { freeLines(scheme->lines, scheme->linesLen); freeStations(scheme->stations, scheme->stationsLen); freeLinks(scheme->links, scheme->linksLen); free(scheme); } }
// -------------------------------------------------------------------------- // Releases COM and frees associated resources. This function should be // called as the very last operation before the application terminates. // Call this function only if a prior call to initializeCOM() returned SL_OK. // // returns: SL_OK under normal circumstances // SL_NOT_INITIALIZED if the reference count indicates that no // current users exist. // -------------------------------------------------------------------------- JNIEXPORT jint JNICALL Java_com_izforge_izpack_util_os_ShellLink_releaseCOM (JNIEnv *env, jobject obj) { referenceCount--; if (referenceCount == 0) { CoUninitialize (); // This is the end of things, so this is a good time to // free the storage for the IShellLink pointers. freeLinks (); return (SL_OK); } else if (referenceCount < 0) { referenceCount++; return (SL_NOT_INITIALIZED); } else { return (SL_OK); } }
/** * This function downloads a package from the internet looking for its mirrors calling the SearchLinkForPackage * @param name A package name * @param out Since this function may get called by InstallPkg, the full path to the package downloaded will be saved here. If null is given, this will not change. * @return If no error ocurr, 0 is returned. If the package doesn't exists in any mirror, 1 is returned. In case of error, -1 (And an error message is issued) */ int DownloadPkg(char *name, char *out) { ListOfLinks Links; char filename[PATH_MAX], pkgcrc[32]; int i = 0, fd = 0; char *MIRROR = NULL; /* Initialize everything up */ memset(&Links, 0, sizeof(ListOfLinks)); /* Search for the package's links */ /* If there is no, 1 is returned, so we leave here */ if ((MIRROR = getenv("MIRROR"))) { if (SearchLinkForPackage(name, &Links, MIRROR)) return 1; } else if (SearchLinkForPackage(name, &Links, NULL)) return 1; if (Links.index > 1) i = GetLinkFromInput(&Links); sprintf(filename, "%s/%s#%s#%s#%s.%s", PACKAGES_DIRECTORY, Links.name[i], Links.version[i], Links.arch[i], Links.build[i], Links.extension[i]); /* If the output already exist and the CRC is ok, then great, we already have it, so there's no need to download it again */ if ((fd = open(filename, O_RDONLY)) >= 0) { close(fd); if (GiveMeHash(filename, pkgcrc) == -1) { freeLinks(&Links); return -1; } if (strcmp(pkgcrc, Links.crcs[i])) fprintf(stderr, "CRC error, Downloading the package again...\n"); else { /* Great, it's already installed, so we leave */ if (out) strcpy(out, filename); freeLinks(&Links); return 0; } } /* Download the link */ if (Download(Links.links[i], filename) == -1) { freeLinks(&Links); return -1; } if (out) strcpy(out, filename); /* Get the link hash */ if (GiveMeHash(filename, pkgcrc) == -1) { freeLinks(&Links); return -1; } /* Does the link hash match with the one given in the database? */ if (strcmp(pkgcrc, Links.crcs[i])) { freeLinks(&Links); fprintf(stderr, "CRC error, try to download your package again\n"); return -1; } /* Great, we're cool, so we leave */ freeLinks(&Links); return 0; }
phdWarpLinkSchema::~phdWarpLinkSchema() { freeLinks(); }