RDB type loading functions clarified in comments.
Improved comments to make clear that rdbLoadType() just loads a general TYPE in the context of RDB that can be an object type or an expire type, end-of-file, and so forth. While rdbLoadObjectType() enforces that the type is a valid Object Type otherwise it returns -1.
This commit is contained in:
parent
1419406e8d
commit
c7a25200e2
@ -21,6 +21,9 @@ int rdbSaveType(rio *rdb, unsigned char type) {
|
|||||||
return rdbWriteRaw(rdb,&type,1);
|
return rdbWriteRaw(rdb,&type,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Load a "type" in RDB format, that is a one byte unsigned integer.
|
||||||
|
* This function is not only used to load object types, but also special
|
||||||
|
* "types" like the end-of-file type, the EXPIRE type, and so forth. */
|
||||||
int rdbLoadType(rio *rdb) {
|
int rdbLoadType(rio *rdb) {
|
||||||
unsigned char type;
|
unsigned char type;
|
||||||
if (rioRead(rdb,&type,1) == 0) return -1;
|
if (rioRead(rdb,&type,1) == 0) return -1;
|
||||||
@ -433,7 +436,8 @@ int rdbSaveObjectType(rio *rdb, robj *o) {
|
|||||||
return -1; /* avoid warning */
|
return -1; /* avoid warning */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load object type. Return -1 when the byte doesn't contain an object type. */
|
/* Use rdbLoadType() to load a TYPE in RDB format, but returns -1 if the
|
||||||
|
* type is not specifically a valid Object Type. */
|
||||||
int rdbLoadObjectType(rio *rdb) {
|
int rdbLoadObjectType(rio *rdb) {
|
||||||
int type;
|
int type;
|
||||||
if ((type = rdbLoadType(rdb)) == -1) return -1;
|
if ((type = rdbLoadType(rdb)) == -1) return -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user