1. Список говнокодов пользователя foxes

    Всего: 2

  2. C++ / Говнокод #19604

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    void checklock(globalMemManager *c)
    	{
    		if (!c->isThread) return;
    		_voidint idl=c->isThread();
    #ifdef THREADDEBUG
    		assert(idl!=0);
    #endif
    		while (idl==0 && c->lock());
    		if (idl!=0) while (true) {
    			while (c->lockId()!=idl) {
    				c->canLeave()=idl;
    			}
    			if (c->lock()) break;
    		}
    		c->lock()=true;
    	}
    
    	void unlock(globalMemManager *c)
    	{
    		if (!c->isThread) return;
    		c->lock()=false;
    #ifdef THREADDEBUG
    		assert(c->lockId()==c->isThread());
    #endif
    		c->canLeave()=0;
    		c->lockId()=0;
    	}
    
    
    	void globalMemManager::manage()
    	{
    		if (!lock()) if (lockId()==0 && canLeave()!=0) {
    			if (!lock()) lock()=true;
    			lockId()=canLeave();
    		}
    	}

    Лучшее

    foxes, 10 Марта 2016

    Комментарии (3)
  3. C++ / Говнокод #19603

    −2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    namespace bt {
    #define MEMNULL \
    	_FORCEINLINE void* operator new(size_t) { return 0; } \
    	_FORCEINLINE void operator delete(void* ) { }
    
    #define MEMDEFAULT(classname) \
    	_FORCEINLINE void* operator new(size_t size) { return extFunctions.CreateMem((unsigned int)size, 0); } \
    	_FORCEINLINE void operator delete(void* val) { extFunctions.DeleteMem(val, 0); }
    
    #define MEMMANAGER(classname) \
    	_FORCEINLINE void* operator new(size_t size) { return bt::internalmemmanager.getNew((unsigned int)size); } \
    	_FORCEINLINE void operator delete(void* val) {bt::internalmemmanager.freeThis(val,sizeof(classname));}
    
    #define MEMMANAGERCLEAN(classname) \
    	_FORCEINLINE void* operator new(size_t size) { return bt::internalmemmanager.getNewClean((unsigned int)size); } \
    	_FORCEINLINE void operator delete(void* val) { bt::internalmemmanager.freeThis(val,sizeof(classname)); }
    
    	class memManagerExport {
    	public:
    		MEMDEFAULT(memManagerExport)
    
    		BT_API memManagerExport(unsigned int size);
    
    		BT_API virtual ~memManagerExport();
    
    		/// destroy all memory segments and free list of free pointers
    		BT_API void _free();
    		/// return pointer to new object and create new segment of objects if need.
    		BT_API void *_addAlloc();
    		/// return pointer to free object
    		BT_API void *_getFree(unsigned int size);
    		/// add pointer to list of free
    		BT_API void _appendToFree(_voidint idat);
    		/// mark pointer to free ???
    		BT_API void _markFree(void* val);
    		/// return number object in segment
    		BT_API unsigned int _valid(unsigned int id);
    		/// return segment number
    		BT_API unsigned int _segid(unsigned int id);
    		/// prepare calculation for object size
    		BT_API void _calcsize(unsigned int size);
    
    	private:
    		enum States {
    			VALIDED = 0x011F1C01,
    			FREE = 0
    		};
    
    		unsigned int fisVal;
    		struct p_smemManager *fargs;
    	};
    
    	class memManager: public memManagerExport {
    	public:
    		MEMDEFAULT(memManager)
    
    		_FORCEINLINE memManager(unsigned int size):memManagerExport(size) {}
    
    		_FORCEINLINE ~memManager() {}
    
    		/// create memory for object
    		_FORCEINLINE void *getNew(unsigned int size) {return (void*)_getFree(size);}
    		/// delete memory for object
    		_FORCEINLINE void freeThis(void * val) {_appendToFree((_voidint)val);}
    		/// destroy all memory segments and free list of free
    		_FORCEINLINE void free() {_free();};
    	};
    
    	class globalMemManager {
    	public:
    		MEMDEFAULT(globalMemManager)
    
    }

    Давайте ржать

    foxes, 10 Марта 2016

    Комментарии (18)