RagePhoto: replace strncmp with memcmp

RagePhoto(A): fix header spelling mistake
RagePhotoA: update header description
This commit is contained in:
Syping 2023-02-24 23:51:32 +01:00
parent d75eba2a46
commit 4ca8ac9297
3 changed files with 8 additions and 8 deletions

View File

@ -352,7 +352,7 @@ bool RagePhoto::load(const char *data, size_t length, RagePhotoData *rp_data, Ra
rp_data->error = Error::IncompleteJpegMarker; // 12 rp_data->error = Error::IncompleteJpegMarker; // 12
return false; return false;
} }
if (strncmp(markerBuffer, "JPEG", 4) != 0) { if (std::memcmp(markerBuffer, "JPEG", 4) != 0) {
rp_data->error = Error::IncorrectJpegMarker; // 13 rp_data->error = Error::IncorrectJpegMarker; // 13
return false; return false;
} }
@ -398,7 +398,7 @@ bool RagePhoto::load(const char *data, size_t length, RagePhotoData *rp_data, Ra
rp_data->error = Error::IncompleteJsonMarker; // 18 rp_data->error = Error::IncompleteJsonMarker; // 18
return false; return false;
} }
if (strncmp(markerBuffer, "JSON", 4) != 0) { if (std::memcmp(markerBuffer, "JSON", 4) != 0) {
rp_data->error = Error::IncorrectJsonMarker; // 19 rp_data->error = Error::IncorrectJsonMarker; // 19
return false; return false;
} }
@ -433,7 +433,7 @@ bool RagePhoto::load(const char *data, size_t length, RagePhotoData *rp_data, Ra
rp_data->error = Error::IncompleteTitleMarker; // 23 rp_data->error = Error::IncompleteTitleMarker; // 23
return false; return false;
} }
if (strncmp(markerBuffer, "TITL", 4) != 0) { if (std::memcmp(markerBuffer, "TITL", 4) != 0) {
rp_data->error = Error::IncorrectTitleMarker; // 24 rp_data->error = Error::IncorrectTitleMarker; // 24
return false; return false;
} }
@ -468,7 +468,7 @@ bool RagePhoto::load(const char *data, size_t length, RagePhotoData *rp_data, Ra
rp_data->error = Error::IncompleteDescMarker; // 28 rp_data->error = Error::IncompleteDescMarker; // 28
return false; return false;
} }
if (strncmp(markerBuffer, "DESC", 4) != 0) { if (std::memcmp(markerBuffer, "DESC", 4) != 0) {
rp_data->error = Error::IncorrectDescMarker; // 29 rp_data->error = Error::IncorrectDescMarker; // 29
return false; return false;
} }
@ -503,7 +503,7 @@ bool RagePhoto::load(const char *data, size_t length, RagePhotoData *rp_data, Ra
rp_data->error = Error::IncompleteJendMarker; // 33 rp_data->error = Error::IncompleteJendMarker; // 33
return false; return false;
} }
if (strncmp(markerBuffer, "JEND", 4) != 0) { if (std::memcmp(markerBuffer, "JEND", 4) != 0) {
rp_data->error = Error::IncorrectJendMarker; // 34 rp_data->error = Error::IncorrectJendMarker; // 34
return false; return false;
} }

View File

@ -115,7 +115,7 @@ public:
int32_t error() const; /**< Returns the last error occurred. */ int32_t error() const; /**< Returns the last error occurred. */
uint32_t format() const; /**< Returns the Photo Format (GTA V or RDR 2). */ uint32_t format() const; /**< Returns the Photo Format (GTA V or RDR 2). */
const std::string jpeg() const; /**< Returns the Photo JPEG data. */ const std::string jpeg() const; /**< Returns the Photo JPEG data. */
const char *jpegData() const; /**< Returns the Photo JPEG data. */ const char* jpegData() const; /**< Returns the Photo JPEG data. */
uint32_t jpegSize() const; /**< Returns the Photo JPEG data size. */ uint32_t jpegSize() const; /**< Returns the Photo JPEG data size. */
const char* description() const; /**< Returns the Photo description. */ const char* description() const; /**< Returns the Photo description. */
const char* json() const; /**< Returns the Photo JSON data. */ const char* json() const; /**< Returns the Photo JSON data. */

View File

@ -28,7 +28,7 @@
* \brief ABI Stable Wrapper for RagePhoto. * \brief ABI Stable Wrapper for RagePhoto.
* *
* Using RagePhotoA instead of RagePhoto allows your library or application to survive more changes in the RagePhoto class, * Using RagePhotoA instead of RagePhoto allows your library or application to survive more changes in the RagePhoto class,
* disadvantages include worse performance, which should be pretty minimal, and not always include the newest features. * disadvantages include that it doesn't always include the newest features, performance is about the same.
*/ */
class RagePhotoA class RagePhotoA
{ {
@ -150,7 +150,7 @@ public:
return std::string(ragephoto_getphotojpeg(instance), ragephoto_getphotosize(instance)); return std::string(ragephoto_getphotojpeg(instance), ragephoto_getphotosize(instance));
} }
/** Returns the Photo JPEG data. */ /** Returns the Photo JPEG data. */
const char *jpegData() const { const char* jpegData() const {
return ragephoto_getphotojpeg(instance); return ragephoto_getphotojpeg(instance);
} }
/** Returns the Photo JPEG data size. */ /** Returns the Photo JPEG data size. */