Data storage method, device, electronic product, and computer-readable storage medium

After obtaining the target storage address in the flash memory, the data is stored at the corresponding address according to the length of the data to be stored, ensuring the continuity of the storage space, solving the problem of waste of flash memory storage space, and achieving efficient data positioning and saving storage space .

CN111767234BActive Publication Date: 2024-11-05GEER TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010599278.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-06-28
Publication Date
2024-11-05
Estimated Expiration
2040-06-28

AI Technical Summary

Technical Problem

When flashing occurs, data location needs to be frequently used for writing or erasing data, resulting in wasted storage space.

Method used

By acquiring the target storage address, the byte length of the continuous free storage space is greater than or equal to the preset byte length, and the data is stored according to the first byte length of the data to be stored at the adjacent storage address after the target storage address, the data is stored to be stored according to the first byte length of the data to be stored, so that the to be stored The byte length of the continuous free storage space after the last byte in the data is also greater than or equal to the preset byte length.

Benefits of technology

Saves storage space, avoids frequent data writing and erasing operations, and extends the memory life.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111767234B_ABST
    Figure CN111767234B_ABST
Patent Text Reader

Abstract

The present invention discloses a data storage method, which includes: obtaining a target storage address, wherein the byte length corresponding to the continuous free storage space after the target storage address is greater than or equal to a preset byte length; obtaining a first byte length of data to be stored; storing the data to be stored at an adjacent storage address after the target storage address according to the first byte length and the preset byte length, so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length. The present invention can locate the storage address of the data to be stored by the preset byte length, and does not need to store the storage address of the data to be stored in the storage space, thus saving storage space. In addition, a data storage device, an electronic product, and a computer-readable storage medium are also proposed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a data storage method, device, electronic product and computer-readable storage medium. Background Art

[0002] Flash memory is a non-volatile memory, and products widely use flash memory as data storage. When flash memory is used as data storage for data storage, the stored data often changes, so data writing or erasing operations need to be performed frequently. When performing data writing or erasing operations, it is necessary to locate the previously written data.

[0003] In the prior art, when writing data into a flash memory, in order to locate the data, it is necessary to store the location information corresponding to the last data in the flash memory, resulting in a waste of storage space of the flash memory. Summary of the invention

[0004] The main purpose of the present invention is to provide a data storage method, device, electronic product and computer-readable storage medium, aiming to solve the problem of waste of flash memory storage space.

[0005] To achieve the above object, the present invention provides a welding control method, which comprises the following steps:

[0006] Obtaining a target storage address, wherein the byte length corresponding to the continuous free storage space after the target storage address is greater than or equal to a preset byte length;

[0007] Get the first byte length of the data to be stored;

[0008] According to the first byte length and the preset byte length, the data to be stored is stored at an adjacent storage address after the target storage address so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length.

[0009] In one embodiment, the step of obtaining the target storage address includes:

[0010] Acquire a target storage sector from among the storage sectors in the memory, wherein the target storage sector has continuous free storage space with a byte length greater than or equal to a preset byte length;

[0011] Obtaining the byte length corresponding to the continuous free storage space after each storage address in the target storage sector;

[0012] The target storage address is determined according to the byte length.

[0013] In one embodiment, the step of obtaining a target storage sector from among the storage sectors in the memory, wherein the target storage sector has continuous free storage space with a byte length greater than or equal to a preset byte length, comprises:

[0014] Acquire the state of the storage area corresponding to the preset storage address in each storage sector, the preset storage address is continuous and located at the end of the storage sector, and the byte length of the storage area corresponding to the preset storage address is the preset byte length;

[0015] The storage sector in the idle state is used as the target storage sector.

[0016] In one embodiment, the step of storing the data to be stored at an adjacent storage address after the target storage address according to the first byte length and the preset byte length includes:

[0017] Obtaining a sum of the first byte length and the preset byte length;

[0018] When the sum is less than or equal to the byte length corresponding to the free storage space in the target storage sector, the data to be stored is stored in a storage address adjacent to the target storage address.

[0019] In one embodiment, the step of storing the data to be stored at an adjacent storage address after the target storage address according to the first byte length and the preset byte length further includes:

[0020] When the sum is greater than the byte length corresponding to the free storage space in the target storage sector, acquiring an adjacent storage sector of the target storage sector;

[0021] According to the byte length corresponding to the free storage space, part of the data to be stored is stored in a storage address adjacent to the target storage address of the target storage sector;

[0022] The remaining data to be stored are stored in the adjacent storage sectors of the target storage sector, so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length.

[0023] In one embodiment, after the step of storing part of the data to be stored at a storage address adjacent to the target storage address of the target storage sector according to the byte length corresponding to the free storage space, the method further includes:

[0024] Determining whether the adjacent storage sector is free storage space;

[0025] If the adjacent storage sector is free storage space, the step of storing the remaining data to be stored in the adjacent storage sector of the target storage sector is performed so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length;

[0026] If the adjacent storage sector is not a free storage space, performing an erasing operation on the adjacent storage sector;

[0027] The remaining data to be stored are stored in the adjacent storage sectors after the erasing operation, so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length.

[0028] In one embodiment, the step of obtaining the adjacent storage sectors of the target storage sector includes:

[0029] When the target storage sector is the last storage sector, the adjacent storage sector is determined to be the first storage sector.

[0030] A data storage device, comprising:

[0031] A first acquisition module is used to acquire a target storage address, wherein the byte length corresponding to the continuous free storage space after the target storage address is greater than or equal to a preset byte length;

[0032] A second acquisition module, used for acquiring a first byte length of the data to be stored;

[0033] A storage module is used to store the data to be stored at an adjacent storage address after the target storage address according to the first byte length and the preset byte length, so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length.

[0034] To achieve the above objectives, the present invention also provides an electronic product, which includes a memory, a processor, and a data storage program stored in the memory and executable on the processor, and when the data storage program is executed by the processor, the various steps of the data storage method described above are implemented.

[0035] To achieve the above object, the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a data storage program, and when the data storage program is executed by a processor, the various steps of the data storage method described above are implemented.

[0036] The data storage method, device, electronic product and computer-readable storage medium provided by the present invention obtain a target storage address, and the byte length corresponding to the continuous free storage space after the target storage address is greater than or equal to the preset byte length; obtain the first byte length of the data to be stored; according to the first byte length and the preset byte length, store the data to be stored at the adjacent storage address after the target storage address, so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length. Since the preset byte length is left after the storage address of the data to be stored, the storage address of the data to be stored can be located by the preset byte length, and the storage address of the data to be stored does not need to be stored in the storage space, thereby saving storage space. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 A schematic diagram of the hardware structure of an electronic product involved in an embodiment of the present invention;

[0038] Figure 2 A schematic diagram of a flow chart of a first embodiment of a data storage method of the present invention;

[0039] Figure 3 This is a detailed flow chart of step S10 in the second embodiment of the data storage method of the present invention;

[0040] Figure 4 It is a schematic diagram of the structure of the storage sector in the memory of the present invention;

[0041] Figure 5 This is a detailed flow chart of step S11 in the third embodiment of the data storage method of the present invention;

[0042] Figure 6 This is a detailed flow chart of step S30 in the fourth embodiment of the data storage method of the present invention;

[0043] Figure 7 This is a detailed flow chart of step S30 in the fifth embodiment of the data storage method of the present invention;

[0044] Figure 8 This is a detailed flow chart of step S30 in the sixth embodiment of the data storage method of the present invention;

[0045] Fig. 9 It is a schematic diagram of the structure of the data storage device of the present invention.

[0046] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0047] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0048] The main solution of an embodiment of the present invention is: obtain a target storage address, the byte length corresponding to the continuous free storage space after the target storage address is greater than or equal to the preset byte length; obtain the first byte length of the data to be stored; store the data to be stored at a storage address adjacent to the target storage address according to the first byte length and the preset byte length, so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length.

[0049] Since a preset byte length is left after the storage address of the data to be stored, the storage address of the data to be stored can be located by the preset byte length, and the storage address of the data to be stored does not need to be stored in the storage space, thus saving storage space.

[0050] As an implementation solution, electronic products can be Figure 1 shown.

[0051] The embodiment of the present invention relates to an electronic product, which includes: a processor 101, such as a CPU, a memory 102, and a communication bus 103. The communication bus 103 is used to realize the connection and communication between these components. The electronic product here can specifically be a smart wearable device such as a smart watch, a smart bracelet, a smart ring, as well as an electronic product that needs data storage, such as a smart headset, a smart speaker, a tracker, a game controller, a smart home, and a smart headset.

[0052] The memory 102 may be a high-speed RAM memory or a stable memory (non-volatile memory), such as a disk memory. Figure 1 As shown, the memory 102 as a computer-readable storage medium may include a data storage program; and the processor 101 may be used to call the data storage program stored in the memory 102 and perform the following operations:

[0053] Obtaining a target storage address, wherein the byte length corresponding to the continuous free storage space after the target storage address is greater than or equal to a preset byte length;

[0054] Get the first byte length of the data to be stored;

[0055] According to the first byte length and the preset byte length, the data to be stored is stored at an adjacent storage address after the target storage address so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length.

[0056] In one embodiment, the processor 101 may be used to call a data storage program stored in the memory 102 and perform the following operations:

[0057] Acquire a target storage sector from among the storage sectors in the memory, wherein the target storage sector has continuous free storage space with a byte length greater than or equal to a preset byte length;

[0058] Obtaining the byte length corresponding to the continuous free storage space after each storage address in the target storage sector;

[0059] The target storage address is determined according to the byte length.

[0060] In one embodiment, the processor 101 may be used to call a data storage program stored in the memory 102 and perform the following operations:

[0061] Acquire the state of the storage area corresponding to the preset storage address in each storage sector, the preset storage address is continuous and located at the end of the storage sector, and the byte length of the storage area corresponding to the preset storage address is the preset byte length;

[0062] The storage sector in the idle state is used as the target storage sector.

[0063] In one embodiment, the processor 101 may be used to call a data storage program stored in the memory 102 and perform the following operations:

[0064] Obtaining a sum of the first byte length and the preset byte length;

[0065] When the sum is less than or equal to the byte length corresponding to the free storage space in the target storage sector, the data to be stored is stored in a storage address adjacent to the target storage address.

[0066] In one embodiment, the processor 101 may be used to call a data storage program stored in the memory 102 and perform the following operations:

[0067] When the sum is greater than the byte length corresponding to the free storage space in the target storage sector, acquiring an adjacent storage sector of the target storage sector;

[0068] According to the byte length corresponding to the free storage space, part of the data to be stored is stored in a storage address adjacent to the target storage address of the target storage sector;

[0069] The remaining data to be stored are stored in the adjacent storage sectors of the target storage sector, so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length.

[0070] In one embodiment, the processor 101 may be used to call a data storage program stored in the memory 102 and perform the following operations:

[0071] Determining whether the adjacent storage sector is free storage space;

[0072] If the adjacent storage sector is free storage space, the step of storing the remaining data to be stored in the adjacent storage sector of the target storage sector is performed so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length;

[0073] If the adjacent storage sector is not a free storage space, performing an erasing operation on the adjacent storage sector;

[0074] The remaining data to be stored are stored in the adjacent storage sectors after the erasing operation, so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length.

[0075] In one embodiment, the processor 101 may be used to call a data storage program stored in the memory 102 and perform the following operations:

[0076] When the target storage sector is the last storage sector, the adjacent storage sector is determined to be the first storage sector.

[0077] Based on the hardware architecture of the above electronic product, an embodiment of a data storage method is proposed.

[0078] Reference Figure 2 , Figure 2 The first embodiment of the data storage method of the present invention comprises the following steps:

[0079] Step S10: Acquire a target storage address, wherein the byte length corresponding to the continuous free storage space after the target storage address is greater than or equal to a preset byte length.

[0080] Specifically, the target storage address is the storage address of the last storage data of the data to be stored, and the last storage data may be a work log; the preset byte length is used to determine the storage address of the last storage data, and when there is continuous free storage space greater than or equal to the preset byte length after the storage address, the storage address is used as the target storage address.

[0081] Step S20: Obtain the first byte length of the data to be stored.

[0082] Specifically, the first byte length is the byte length of the data to be stored. The data to be stored may be a log file. The log file mainly records the information of the interaction between the system and the user. The log file is used to record information related to activities of Internet technology resources such as servers, workstations, firewalls and application software. For example, the records generated during the software installation process can be provided to the uninstaller for use in the future when uninstalling. The file name is generally uninstall.log; it is used to record error information during the operation of the software. The file name is generally error.log. The data to be stored is not limited to log files. The data to be stored may also be other data, such as video files or audio files.

[0083] Step S30: According to the first byte length and the preset byte length, the data to be stored is stored at an adjacent storage address after the target storage address, so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length.

[0084] Specifically, based on the first byte length of the data to be stored and the preset byte length, it is determined whether the adjacent storage address of the target storage address can store the data to be stored, and a continuous free storage space with a reserved byte length greater than or equal to the preset byte length after the last byte in the data to be stored is reserved.

[0085] In the technical solution provided in this embodiment, after the data to be stored is stored in the target storage address, since a preset byte length is left after the storage address of the data to be stored, the storage address of the data to be stored can be located by the preset byte length, and there is no need to store the storage address of the data to be stored in the storage space, which saves storage space and avoids frequent writing and erasing of data, shortening the life of the memory.

[0086] Reference Figure 3 , Figure 3 This is a second embodiment of the data storage method of the present invention, based on the first embodiment, step S10 includes:

[0087] Step S11: obtaining a target storage sector from among the storage sectors in the memory, wherein the target storage sector has continuous free storage space with a byte length greater than or equal to a preset byte length.

[0088] Specifically, the memory is a memory device for storing information, and the memory may be a flash memory, a memory card, or a digital film, etc. Among them, the distribution of each storage sector in the memory and three examples of storage status can be represented by Figure 4As shown, case 1 is to store data in the idle storage sectors in turn, and case 2 and case 3 are to store the data to be stored in the storage sectors that have already stored data. In each storage sector of the memory, it is determined that there is a storage sector whose byte length is greater than or equal to the preset byte length, and the storage sector is used as the target storage sector. The target storage sector is the storage sector that stores the last stored data.

[0089] Step S12: Obtain the byte length corresponding to the continuous free storage space after each storage address in the target storage sector.

[0090] Specifically, the byte length corresponding to the continuous free storage space after each storage address in the target storage sector is obtained, and the byte length after each storage address can be a preset byte length, a byte length between zero and the preset byte length, or a byte length greater than the preset byte length. Therefore, the target storage address can be judged by the byte length corresponding to the continuous free storage space after each storage address.

[0091] Step S13: Determine the target storage address according to the byte length.

[0092] Specifically, when the byte length corresponding to the continuous free storage space after each storage address meets the preset condition, the storage address corresponding to the byte length meeting the preset condition is determined as the target storage address. The preset condition here can be that the byte length corresponding to the continuous free storage space after each storage address is equal to the preset byte length, or that the byte length corresponding to the continuous free storage space after each storage address meets the preset byte length range.

[0093] In the technical solution provided in this embodiment, by obtaining the target storage sector whose byte length corresponding to the continuous free storage space in each storage sector in the memory is greater than or equal to the preset byte length, the byte length corresponding to the continuous free storage space after each storage address in the target storage sector is judged, and the target storage address corresponding to the previous storage data is determined, thereby determining the storage location of the data to be stored.

[0094] Reference Figure 5 , Figure 5 This is a third embodiment of the data storage method of the present invention, based on the first or second embodiment, the step S11 includes:

[0095] Step S111: obtaining the status of the storage area corresponding to the preset storage address in each storage sector, wherein the preset storage address is continuous and located at the end of the storage sector, and the byte length of the storage area corresponding to the preset storage address is the preset byte length.

[0096] Step S112: taking the storage sector in the idle state as the target storage sector.

[0097] Specifically, the target storage sector is a storage sector storing the last stored data. The state of the storage area corresponding to the preset storage address is determined in each storage sector, wherein the preset storage address is located at the end of the storage sector, the preset storage address is a continuous storage area, and the byte length of the storage area is the preset byte length. And the state of the storage area corresponding to the preset storage address can be an idle state or a non-idle state, that is, a state in which data is stored.

[0098] By selecting the state of the storage area corresponding to the preset storage address in each storage sector, the storage sector in the idle state is used as the target storage sector.

[0099] If there are multiple storage sectors in the idle state, the first storage sector in the idle state is used as the target storage sector.

[0100] In the technical solution provided in this embodiment, the target storage sector for storing the last stored data is determined among multiple storage sectors, thereby determining the target storage address corresponding to the last stored data in the target sector, thereby narrowing the range of the target storage address.

[0101] Reference Figure 6 , Figure 6 This is a fourth embodiment of the data storage method of the present invention, based on any one of the first to third embodiments, step S30 includes:

[0102] Step S31: Obtain the sum of the first byte length and the preset byte length.

[0103] Step S32: When the sum value is less than or equal to the byte length corresponding to the free storage space in the target storage sector, the data to be stored is stored in a storage address adjacent to the target storage address.

[0104] Specifically, the sum of the first byte length and the preset byte length is calculated and compared with the byte length corresponding to the free storage space in the target storage sector. The sum of the first byte length and the preset byte length is less than or equal to the byte length corresponding to the continuous free storage space after the target storage address, that is, there is enough storage space after the target storage address to store the data to be stored and it can be guaranteed that there is storage space of the preset byte length after the data to be stored.

[0105] In the technical solution provided in this embodiment, the storage address of the data to be stored is determined according to the first byte length of the data to be stored and the preset byte length, the data to be stored is stored in a storage address adjacent to the target storage address in the target storage sector, and storage space of the preset byte length is reserved after the storage address.

[0106] Reference Figure 7 , Figure 7 This is a fifth embodiment of the data storage method of the present invention, based on any one of the first to fourth embodiments, step S30 includes:

[0107] Step S33: when the sum value is greater than the byte length corresponding to the free storage space in the target storage sector, acquiring the adjacent storage sectors of the target storage sector.

[0108] Specifically, when the sum of the first byte length and the preset byte length is greater than the byte length corresponding to the continuous free storage space after the target storage address, the continuous free storage space after the target storage address cannot store the data to be stored with the first byte length, or can store the data to be stored with the first byte length, but cannot leave storage space of the preset byte length after the data to be stored, so it is necessary to determine the adjacent storage sectors of the target storage sector.

[0109] Step S34: according to the byte length corresponding to the free storage space, part of the data to be stored is stored in a storage address adjacent to the target storage address of the target storage sector.

[0110] Specifically, when the first byte length is greater than the byte length corresponding to the continuous free storage space after the target storage address, the data to be stored is stored in the target storage area and the adjacent storage area, that is, the data to be stored is stored in the adjacent storage address of the target storage address and the storage address in the adjacent storage sector.

[0111] Part of the data to be stored is stored in a storage address adjacent to the target storage address of the target storage sector, wherein the byte length of the part of the data is consistent with the byte length corresponding to the free storage space.

[0112] Step S35: storing the remaining data to be stored in the adjacent storage sector of the target storage sector, so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length.

[0113] Specifically, the remaining data to be stored is stored in a storage sector adjacent to the target storage sector, wherein the remaining data to be stored is the difference between the byte length of the data to be stored and the byte length corresponding to the free storage space.

[0114] When the first byte length is smaller than the byte length corresponding to the continuous free storage space after the target storage address, the data to be stored is stored in the target storage area, and the preset byte length after the data to be stored is stored in the target storage area, or the target storage area and the adjacent storage area.

[0115] In the technical solution provided in this embodiment, the storage address of the data to be stored is determined according to the first byte length and the preset byte length of the data to be stored, the data to be stored is stored in the target storage sector and the adjacent storage sector, and storage space of the preset byte length is reserved after the storage address.

[0116] Reference Figure 8 , Figure 8 This is the sixth embodiment of the data storage method of the present invention, based on the fifth embodiment, and after step S34, further comprising:

[0117] Step S341: Determine whether the adjacent storage sector is free storage space.

[0118] Specifically, the adjacent storage space of the target storage space can be an idle storage space, in which case the data to be stored can be directly stored in the adjacent storage sector; or it can be a storage space that has already stored data, in which case the data to be stored cannot be directly stored in the adjacent storage sector. Therefore, before storing the data to be stored in the adjacent storage space, it is necessary to determine whether the adjacent storage sector is an idle storage space.

[0119] Step S342: If the adjacent storage sector is free storage space, the step of storing the remaining data to be stored in the adjacent storage sector of the target storage sector is performed so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length.

[0120] Specifically, when the adjacent storage sector is free storage space, the data to be stored is stored in the adjacent storage address of the target storage address and the storage address in the adjacent storage sector.

[0121] Step S343: If the adjacent storage sector is not free storage space, erase the adjacent storage sector; store the remaining data to be stored in the adjacent storage sector after the erase operation, so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length.

[0122] Specifically, when the adjacent storage sector is not free storage space, an erase operation is performed on the adjacent storage sector, and the erase operation is used to clear the data originally stored in the adjacent storage sector so that the data to be stored can be stored in the adjacent storage sector. After the erase operation is performed, the remaining data to be stored is stored in the adjacent storage sector after the erase operation.

[0123] When the target storage sector is the last storage sector, the adjacent storage sector is determined to be the first storage sector. Figure 4 As shown, each storage sector is a plurality of continuous storage sectors, and data is stored sequentially from the first storage sector to the last storage sector. When the target storage sector is the last storage sector, the adjacent storage sector of the target storage sector is the first storage sector.

[0124] In the technical solution provided in this embodiment, the storage status of the adjacent storage sectors is judged, and the adjacent storage sectors storing data are erased, so that the data to be stored can be stored in the target storage sector and the adjacent storage sectors.

[0125] Reference Fig. 9 , Fig. 9 The data storage device of the present invention comprises:

[0126] A first acquisition module 100 is used to acquire a target storage address, wherein the byte length corresponding to the continuous free storage space after the target storage address is greater than or equal to a preset byte length;

[0127] A second acquisition module 200 is used to acquire a first byte length of data to be stored;

[0128] The storage module 300 is used to store the data to be stored at an adjacent storage address after the target storage address according to the first byte length and the preset byte length, so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length.

[0129] The present invention also provides an electronic product, which includes a memory, a processor, and a data storage program stored in the memory and executable on the processor, wherein the data storage program, when executed by the processor, implements the various steps of the data storage method described in the above embodiment.

[0130] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a data storage program, and when the data storage program is executed by a processor, the various steps of the data storage method described in the above embodiment are implemented.

[0131] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0132] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0133] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a computer-readable storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0134] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A data storage method, characterized in that: The data storage method comprises: Acquire a target storage address, wherein the byte length corresponding to the continuous free storage space after the target storage address is greater than or equal to a preset byte length, and the preset byte length is used to locate the storage address of the data to be stored; Get the first byte length of the data to be stored; According to the first byte length and the preset byte length, the data to be stored is stored at an adjacent storage address after the target storage address so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length.

2. The data storage method according to claim 1, characterized in that: The step of obtaining the target storage address comprises: Acquire a target storage sector from among the storage sectors in the memory, wherein the target storage sector has continuous free storage space with a byte length greater than or equal to a preset byte length; Obtaining the byte length corresponding to the continuous free storage space after each storage address in the target storage sector; The target storage address is determined according to the byte length.

3. The data storage method according to claim 2, characterized in that: The step of obtaining a target storage sector from among the storage sectors in the memory, wherein the target storage sector has continuous free storage space with a byte length greater than or equal to a preset byte length, comprises: Acquire the state of the storage area corresponding to the preset storage address in each storage sector, the preset storage address is continuous and located at the end of the storage sector, and the byte length of the storage area corresponding to the preset storage address is the preset byte length; The storage sector in the idle state is used as the target storage sector.

4. The data storage method according to claim 1, characterized in that: The step of storing the data to be stored at an adjacent storage address after the target storage address according to the first byte length and the preset byte length comprises: Obtaining a sum of the first byte length and the preset byte length; When the sum is less than or equal to the byte length corresponding to the free storage space in the target storage sector, the data to be stored is stored in a storage address adjacent to the target storage address.

5. The data storage method according to claim 4, characterized in that: The step of storing the data to be stored at an adjacent storage address after the target storage address according to the first byte length and the preset byte length further includes: When the sum is greater than the byte length corresponding to the free storage space in the target storage sector, acquiring an adjacent storage sector of the target storage sector; According to the byte length corresponding to the free storage space, part of the data to be stored is stored in a storage address adjacent to the target storage address of the target storage sector; The remaining data to be stored are stored in the adjacent storage sectors of the target storage sector, so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length.

6. The data storage method according to claim 5, characterized in that: After the step of storing part of the data to be stored in the adjacent storage address of the target storage address of the target storage sector according to the byte length corresponding to the free storage space, the method further includes: Determining whether the adjacent storage sector is free storage space; If the adjacent storage sector is free storage space, the step of storing the remaining data to be stored in the adjacent storage sector of the target storage sector is performed so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length; If the adjacent storage sector is not a free storage space, performing an erasing operation on the adjacent storage sector; The remaining data to be stored are stored in the adjacent storage sectors after the erasing operation, so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length.

7. The data storage method according to claim 5, characterized in that: The step of obtaining the adjacent storage sectors of the target storage sector comprises: When the target storage sector is the last storage sector, the adjacent storage sector is determined to be the first storage sector.

8. A data storage device, characterized in that: The data storage device comprises: A first acquisition module is used to acquire a target storage address, wherein the byte length corresponding to the continuous free storage space after the target storage address is greater than or equal to a preset byte length, and the preset byte length is used to locate the storage address of the data to be stored; A second acquisition module, used for acquiring a first byte length of the data to be stored; A storage module is used to store the data to be stored at an adjacent storage address after the target storage address according to the first byte length and the preset byte length, so that the byte length corresponding to the continuous free storage space after the last byte in the data to be stored is greater than or equal to the preset byte length.

9. An electronic product, characterized in that: The electronic product includes a memory, a processor, and a data storage program stored in the memory and executable on the processor, and when the data storage program is executed by the processor, the various steps of the data storage method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a data storage program, and when the data storage program is executed by a processor, each step of the data storage method according to any one of claims 1 to 7 is implemented.