Giter VIP home page Giter VIP logo

Comments (5)

rombust avatar rombust commented on July 18, 2024

I would be happy to change int to size_t. Although I don't plan to use greater than 2^31 sized files, I cannot see any disadvantages in changing it.

from clanlib.

dpjudas avatar dpjudas commented on July 18, 2024

I don't mind such a change, although it should be noted that if you use size_t then 32-bit builds will still not be able to handle files greater than 2^32. One could argue that int64_t is the better choice.

from clanlib.

ArtHome12 avatar ArtHome12 commented on July 18, 2024

Thanks for the opinions. I suggest to stop on size_t. A 32-bit program probably does not need to open files larger than 2 ^ 32, since it can not address so much memory.

In fact, I am motivated by a simpler goal. Some code analyzer gives me warnings that using a signed type for the size is unsafe and I agree with this, although in practice it is still now unlikely. :)

Today or tomorrow I will offer a commit for review.

from clanlib.

ArtHome12 avatar ArtHome12 commented on July 18, 2024

Report about pull request

I started with IODevice.cpp and remade from int to size_t all the related files. Into subsection core/zip did not dive, limited to cosmetics at the interface level. Although there is an unsafe code, for example - forced conversion from int64_t to int:

     int64_t pos;
     ...
     int ZipIODevice_FileEntry::get_position() const
	{
		return (int)pos;
	}

I do not use zip and will not be able to test its performance. At least it became no worse.

Also did not touch the seek functions. Their change is non-trivial and requires separate testing and experience of WinAPI (and others OS). As result - and early and now it is impossible to move the pointer in the file more than 2^31 bytes.

Further, thanks to the code analyzer (PVS) was convinced that it had not added any new problems, and also slightly improved the existing code in the changed files to exclude the following warnings:

In conclusion, compiled all the examples (45/47 successful, 2 - I have no "assimp/cimport.h" for Object3D and Quaternion) and made sure that they did not crush. The examples "Layered Window" and "Layered Window 2" crashes with OpenGL INVALID_ENUM but it had chashed before my changes too. And finally test my own project, which actively uses file.read() and write(). No problems detected.

from clanlib.

ArtHome12 avatar ArtHome12 commented on July 18, 2024

Found a small problem to fix in the next commit:
File iodevice_provider.h, overdid with copy-pase:

virtual size_t receive(void *data, **size_t size_t**, bool receive_all = true) = 0;
virtual size_t peek(void *data, **size_t size_t**) = 0;

In .cpp all is correct size_t len

from clanlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.