mirror of
https://git.openafs.org/openafs.git
synced 2025-01-19 07:20:11 +00:00
STABLE12-add-useful-string-functions-20020822
Add two useful functions for string operations: afs_strdup() and
afs_osi_FreeStr(). Will be used by an upcoming patch.
(cherry picked from commit 5d36376c07
)
This commit is contained in:
parent
cdb8a859c4
commit
cc4b04cf84
@ -932,6 +932,11 @@ void afs_osi_Free(void *ptr, size_t size)
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
void afs_osi_FreeStr(char *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
void *osi_AllocLargeSpace(size_t size)
|
||||
{
|
||||
AFS_STATCNT(osi_AllocLargeSpace);
|
||||
|
@ -1386,7 +1386,9 @@ int SRXAFSCB_GetCellByNum(struct rx_call *a_call, afs_int32 a_cellnum,
|
||||
afs_int32 i, sn;
|
||||
struct cell *tcell;
|
||||
|
||||
RX_AFS_GLOCK();
|
||||
#ifdef RX_ENABLE_LOCKS
|
||||
AFS_GLOCK();
|
||||
#endif /* RX_ENABLE_LOCKS */
|
||||
AFS_STATCNT(SRXAFSCB_GetCellByNum);
|
||||
|
||||
a_hosts->serverList_val = 0;
|
||||
@ -1395,7 +1397,9 @@ int SRXAFSCB_GetCellByNum(struct rx_call *a_call, afs_int32 a_cellnum,
|
||||
tcell = afs_GetCellStale(a_cellnum, READ_LOCK);
|
||||
if (!tcell) {
|
||||
*a_name = afs_strdup("");
|
||||
RX_AFS_GUNLOCK();
|
||||
#ifdef RX_ENABLE_LOCKS
|
||||
AFS_GUNLOCK();
|
||||
#endif /* RX_ENABLE_LOCKS */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1412,7 +1416,9 @@ int SRXAFSCB_GetCellByNum(struct rx_call *a_call, afs_int32 a_cellnum,
|
||||
ReleaseReadLock(&tcell->lock);
|
||||
afs_PutCell(tcell, READ_LOCK);
|
||||
|
||||
RX_AFS_GUNLOCK();
|
||||
#ifdef RX_ENABLE_LOCKS
|
||||
AFS_GUNLOCK();
|
||||
#endif /* RX_ENABLE_LOCKS */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -494,6 +494,10 @@ void afs_osi_Free(void *x, size_t asize)
|
||||
#endif
|
||||
}
|
||||
|
||||
void afs_osi_FreeStr(char *x)
|
||||
{
|
||||
afs_osi_Free(x, strlen(x) + 1);
|
||||
}
|
||||
|
||||
/* ? is it moderately likely that there are dirty VM pages associated with
|
||||
* this vnode?
|
||||
|
@ -110,6 +110,7 @@ extern void afs_GCPAGs_perproc_func(AFS_PROC *pproc);
|
||||
extern char *afs_cv2string(char *ttp, afs_uint32 aval);
|
||||
extern int afs_strcasecmp(char *s1, char *s2);
|
||||
extern char *afs_strchr(char *s, int c);
|
||||
extern char *afs_strdup(char *s);
|
||||
extern void print_internet_address(char *preamble, struct srvAddr *sa,
|
||||
char *postamble, int flag);
|
||||
extern afs_int32 afs_data_pointer_to_int32(const void *p);
|
||||
|
@ -81,6 +81,35 @@ char *afs_strchr(char *s, int c)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int afs_strcasecmp(char *s1, char *s2)
|
||||
{
|
||||
while (*s1 && *s2) {
|
||||
char c1, c2;
|
||||
|
||||
c1 = *s1++;
|
||||
c2 = *s2++;
|
||||
if (c1 >= 'A' && c1 <= 'Z') c1 += 0x20;
|
||||
if (c2 >= 'A' && c2 <= 'Z') c2 += 0x20;
|
||||
if (c1 != c2)
|
||||
return c1-c2;
|
||||
}
|
||||
|
||||
return *s1 - *s2;
|
||||
}
|
||||
|
||||
char *afs_strdup(char *s)
|
||||
{
|
||||
char *n;
|
||||
int cc;
|
||||
|
||||
cc = strlen(s) + 1;
|
||||
n = (char *) afs_osi_Alloc(cc);
|
||||
if (n)
|
||||
memcpy(n, s, cc);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
void print_internet_address(char *preamble, struct srvAddr *sa,
|
||||
char *postamble, int flag)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user