Skip to content

Instantly share code, notes, and snippets.

View dmikurube's full-sized avatar

Dai MIKURUBE dmikurube

View GitHub Profile
@dmikurube
dmikurube / gist:2786440
Created May 25, 2012 07:40
Force global operator new/delete
int main() {
Class* x = ::new Class();
::delete x;
return 0;
}
if (getLangOpts().InterceptAllocationFunctions &&
getLangOpts().RTTI) {
bool UseSize = false;
IdentifierInfo *DeleteInterceptInfo =
&PP.getIdentifierTable().get("__op_delete_intercept__");
DeclareGlobalAllocatorInterceptFunctions(
DeclarationName(DeleteInterceptInfo), UseSize);
LookupResult R(*this, DeleteInterceptInfo, SourceLocation(),
LookupOrdinaryName);
// RUN: clang++ -fintercept-allocation typeaware.cpp
#include <stdio.h>
#include <typeinfo>
#include <iostream>
struct Klass {
int x, y, z;
Klass() { x = 1; y = 2; z = 3; }
~Klass() { x = 0; }
};
class Base(object):
def public(self):
print "base:public"
def call_private(self):
self._private()
def call_hidden(self):
self.__hidden()
class PredictableIterator(object):
def __init__(self, iterator):
self.iterator = iter(iterator)
self._next = None
def __iter__(self): return self
def next(self):
if self._next:
result = self._next
class Base(object):
def __init__(self, x):
self._hoge = x
@staticmethod
def generate(n, x):
if n == 0:
return Sub0(x)
return Sub1(x)
def test(x, y=[], z=list()):
y.append(x)
print y
z.append(x)
print z
test('foo')
test(42)
test(None)
#!/usr/bin/env python
dct = {}
dct['foo'] = {}
dct['bar'] = {}
dct['baz'] = []
foo = dct['foo']
foo['alpha'] = 42
foo['beta'] = 31
from proxy import target
target.Print()
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#define A1 (1024 * 1024 * 200)
#define A2_PARENT (1024 * 1024 * 300)
#define A2_CHILD (1024 * 1024 * 500)
int main() {