MCPcopy Index your code
hub / github.com/MapServer/MapServer / msTmpFilename

Function msTmpFilename

maputil.c:1424–1445  ·  view source on GitHub ↗

* msTmpFilename() * * Generate a Unique temporary filename. * * Returns char* which must be freed by caller. **********************************************************************/

Source from the content-addressed store, hash-verified

1422 * Returns char* which must be freed by caller.
1423 **********************************************************************/
1424char *msTmpFilename(const char *ext)
1425{
1426 char *tmpFname;
1427 int tmpFnameBufsize;
1428 char *fullFname;
1429 char tmpId[128]; /* big enough for time + pid + ext */
1430
1431 snprintf(tmpId, sizeof(tmpId), "%lx_%x",(long)time(NULL),(int)getpid());
1432
1433 if (ext == NULL) ext = "";
1434 tmpFnameBufsize = strlen(tmpId) + 10 + strlen(ext) + 1;
1435 tmpFname = (char*)msSmallMalloc(tmpFnameBufsize);
1436
1437 msAcquireLock( TLOCK_TMPFILE );
1438 snprintf(tmpFname, tmpFnameBufsize, "%s_%x.%s", tmpId, tmpCount++, ext);
1439 msReleaseLock( TLOCK_TMPFILE );
1440
1441 fullFname = strdup(tmpFname);
1442 free(tmpFname);
1443
1444 return fullFname;
1445}
1446
1447/**
1448 * Generic function to Initalize an image object.

Callers 2

msTmpFileFunction · 0.85
image.cFile · 0.85

Calls 4

msSmallMallocFunction · 0.85
msAcquireLockFunction · 0.85
msReleaseLockFunction · 0.85
strdupFunction · 0.85

Tested by

no test coverage detected